Skip to content

Commit

Permalink
Merge branch 'backdrop:1.x' into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
herbdool authored Oct 4, 2024
2 parents c369977 + 3149396 commit 25f7562
Show file tree
Hide file tree
Showing 324 changed files with 4,209 additions and 1,307 deletions.
9 changes: 9 additions & 0 deletions .cspell/backdrop.dic
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ datelimits
dbinfo
dblog
DDTHH
deconstructor
dependee
dependees
derf
Expand Down Expand Up @@ -257,7 +258,9 @@ mouton
moutons
msgbox
multibundle
multilanguage
multipage
multisite
multisites
Műveletek
myclass
Expand Down Expand Up @@ -340,6 +343,12 @@ pneum
Ponedjeljak
preenable
Prefilter
preinstall
preinstalled
preinstalling
prepopulate
prepopulated
prepopulating
prevdate
prevdatealt
prevfirst
Expand Down
2 changes: 1 addition & 1 deletion core/includes/bootstrap.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* The current system version.
*/
define('BACKDROP_VERSION', '1.29.x-dev');
define('BACKDROP_VERSION', '1.30.x-dev');

/**
* Core API compatibility.
Expand Down
23 changes: 23 additions & 0 deletions core/includes/database/mysql/database.inc
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,29 @@ class DatabaseConnection_mysql extends DatabaseConnection {
return 'mysql';
}

/**
* Returns the version of the database server.
*/
public function version() {
$version = parent::version();

// Some MariaDB version strings prepend a fake MySQL version to the front,
// which is always "5.5.5-". This was done to so that old MySQL clients
// could connect to newer MariaDB servers.
// For example, 5.5.5-10.5.11-MariaDB:
// - 5.5.5 is a fake MySQL version.
// - 10.5.11 would be the actual MariaDB version.
// See https://github.com/MariaDB/server/blob/f6633bf058802ad7da8196d01fd19d75c53f7274/include/mysql_com.h#L42
// Remove any leading MySQL 5.5.5- prefixes:
$regex = '/^(?:5\.5\.5-)?(\d+\.\d+\.\d+.*-mariadb.*)/i';
preg_match($regex, $version, $matches);
if (!empty($matches[1])) {
$version = $matches[1];
}

return $version;
}

public function databaseType() {
return 'mysql';
}
Expand Down
1 change: 1 addition & 0 deletions core/includes/drupal.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,7 @@ function drupal_tempnam($directory, $prefix) {
* Creates a .htaccess file in the given directory.
*
* @deprecated since 1.0.0
* @see file_save_htaccess()
*/
function file_create_htaccess($directory, $private = TRUE, $force_overwrite = FALSE) {
watchdog_deprecated_function('drupal', __FUNCTION__);
Expand Down
7 changes: 4 additions & 3 deletions core/includes/file.inc
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS

$htaccess_lines = file_htaccess_lines($private);

// Write the .htaccess file.
if (file_put_contents($htaccess_path, $htaccess_lines)) {
// Write the .htaccess file. Suppress any PHP error and write to watchdog.
if (@file_put_contents($htaccess_path, $htaccess_lines)) {
backdrop_chmod($htaccess_path, 0444);
}
else {
Expand Down Expand Up @@ -2372,7 +2372,8 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
$uri = "$dir/$filename";
$uri = file_stream_wrapper_uri_normalize($uri);
if (is_dir($uri) && $options['recurse']) {
// Give priority to files in this folder by merging them in after any subdirectory files.
// Give priority to files in this folder by merging them in after any
// subdirectory files.
$files = array_merge(file_scan_directory($uri, $mask, $options, $depth + 1), $files);
}
elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) {
Expand Down
38 changes: 32 additions & 6 deletions core/includes/icon.inc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function icon_get_info($icon_name = NULL) {
* Returns HTML for an inline-icon.
*
* This effectively returns the contents of an SVG file. But it could
* potentially be override to replace inlined SVGs with other mechanisms, like
* potentially be overridden to replace inlined SVGs with other mechanisms, like
* an icon font.
*
* @param array $variables
Expand All @@ -282,20 +282,46 @@ function icon_get_info($icon_name = NULL) {
* - attributes: Attributes to be added to the icon itself.
*
* @return string
* The HTML output.
* The HTML output.
*
* @since 1.28.0 Function added.
* @since 1.28.1 The <ellipse>, <line>, <polygon> and <polyline> SVG elements
* are allowed.
*/
function theme_icon(array $variables) {
// Ensure the filename is .svg.
if (image_is_svg($variables['path'])) {
// Ensure the file contents are an SVG.
$svg_contents = file_get_contents($variables['path']);
if (strpos($svg_contents, '<svg') === 0) {
// Clean out any embedded XSS within the SVG. This very-restrictive set
// of options should be adequate for icons.
$svg_contents = filter_xss($svg_contents, array('svg', 'use', 'title',
'desc', 'defs', 'linearGradient', 'stop', 'rect', 'circle', 'path'));
// Allow basic shapes. See:
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element#basic_shapes.
$allowed_svg_basic_shapes = array(
'circle',
'ellipse',
'line',
'polygon',
'polyline',
'rect',
);

// Allow some other elements. This very-restrictive set of options should
// be adequate for icons.
$allowed_svg_other = array(
'defs',
'desc',
'linearGradient',
'path',
'stop',
'svg',
'title',
'use',
);

$allowed_svg_elements = array_merge($allowed_svg_basic_shapes, $allowed_svg_other);

// Clean out any embedded XSS within the SVG.
$svg_contents = filter_xss($svg_contents, $allowed_svg_elements);

// Move the "alt" text to an attribute.
if ($variables['alt']) {
Expand Down
15 changes: 9 additions & 6 deletions core/includes/image.inc
Original file line number Diff line number Diff line change
Expand Up @@ -584,18 +584,21 @@ function image_is_svg($uri) {
function image_add_svg_attributes($svg_content, array $attributes) {
$doc = new DOMDocument();
$doc->loadXML($svg_content);
$svg_tag = $doc->getElementsByTagName('svg')->item(0);

// Convert the alt attribute to a <title> element.
if (isset($attributes['alt'])) {
try {
if (strlen($attributes['alt'])) {
$title = $doc->createElement('title');
$title->textContent = $attributes['alt'];
$doc->firstChild->prepend($title);
// Since DOMDocument::prepend() is not available in PHP versions prior
// to v8, we are using DOMNode::insertBefore().
$svg_tag->insertBefore($title, $svg_tag->firstChild);
}
// Remove any given <title> element if alt is an empty string.
elseif ($doc->firstChild->firstChild && $doc->firstChild->firstChild->nodeName === 'title') {
$doc->firstChild->removeChild($doc->firstChild->firstChild);
elseif ($svg_tag->firstChild && $svg_tag->firstChild->nodeName === 'title') {
$svg_tag->removeChild($svg_tag->firstChild);
}
} catch (DOMException $e) {}
unset($attributes['alt']);
Expand All @@ -604,13 +607,13 @@ function image_add_svg_attributes($svg_content, array $attributes) {
foreach ($attributes as $attribute_name => $attribute_value) {
$attribute_value = implode(' ', (array) $attribute_value);
if (strlen($attribute_value)) {
$doc->firstChild->setAttribute($attribute_name, $attribute_value);
$svg_tag->setAttribute($attribute_name, $attribute_value);
}
else {
$doc->firstChild->removeAttribute($attribute_name);
$svg_tag->removeAttribute($attribute_name);
}
}
return $doc->saveXML($doc->firstChild);
return $doc->saveXML($svg_tag);
}

/**
Expand Down
Loading

0 comments on commit 25f7562

Please sign in to comment.