diff options
author | Mario <mario@mariovavti.com> | 2024-03-08 08:42:50 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-03-08 08:42:50 +0000 |
commit | 45b1be8962903868c5d3a5e98ff09bd74bbecc85 (patch) | |
tree | 97f0594d86662fa40fc3f71012c2714bb3fb228a /include/bbcode.php | |
parent | fe9ca30c5e3061e1f8a7def634392d9fc267790e (diff) | |
download | volse-hubzilla-45b1be8962903868c5d3a5e98ff09bd74bbecc85.tar.gz volse-hubzilla-45b1be8962903868c5d3a5e98ff09bd74bbecc85.tar.bz2 volse-hubzilla-45b1be8962903868c5d3a5e98ff09bd74bbecc85.zip |
inbound support for custom emojis
Diffstat (limited to 'include/bbcode.php')
-rw-r--r-- | include/bbcode.php | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 6bb63bbaf..848d117fb 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -869,11 +869,13 @@ function bb_imgoptions($match) { // [img|zmg=wwwxhhh float=left|right alt=alt text]url[/img|zmg] $local_match = null; - $width = 0; - $float = false; - $alt = false; - - $style = EMPTY_STR; + $width = EMPTY_STR; + $height = EMPTY_STR; + $float = EMPTY_STR; + $alt = EMPTY_STR; + $title = EMPTY_STR; + $style = EMPTY_STR; + $class = EMPTY_STR; $attributes = $match[3]; @@ -882,6 +884,16 @@ function bb_imgoptions($match) { $alt = $matches[1]; } + $x = preg_match("/title=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $title = $matches[1]; + } + + $x = preg_match("/title='(.*?)'/ism", $attributes, $matches); + if ($x) { + $title = $matches[1]; + } + $x = preg_match("/alt=\"\;(.*?)\"\;/ism", $attributes, $matches); if ($x) { $alt = $matches[1]; @@ -907,16 +919,27 @@ function bb_imgoptions($match) { $height = $matches[1]; } + $x = preg_match("/class='(.*?)'/ism", $attributes, $matches); + if ($x) { + $class = $matches[1]; + } + + $x = preg_match("/class=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $class = $matches[1]; + } + +/* should probably sanitize css somehow $x = preg_match("/style='(.*?)'/ism", $attributes, $matches); if ($x) { - $style = $matches[1]; + $style = $matches[1] . ' '; } $x = preg_match("/style=\"\;(.*?)\"\;/ism", $attributes, $matches); if ($x) { - $style = $matches[1]; + $style = $matches[1] . ' '; } - +*/ // legacy img options if ($match[2] === '=') { @@ -932,6 +955,7 @@ function bb_imgoptions($match) { $float = 'left'; $match[3] = substr($match[3],$n + 10); } + if ($n = strpos($match[3],'float=right') !== false) { $float = 'right'; $match[3] = substr($match[3],$n + 11); @@ -947,18 +971,25 @@ function bb_imgoptions($match) { $output = '<img ' . (($match[1] === 'z') ? 'class="zrl" loading="eager"' : '') . ' '; if ($width) { - $style .= 'width: 100%; max-width: ' . $width . 'px; '; + $style .= 'width: ' . intval($width) . 'px; '; } - else { - $style .= 'max-width: 100%; '; + + if ($height) { + $style .= 'height: ' . intval($height) . 'px; '; } + if ($float) { $style .= 'float: ' . $float . '; '; } - $output .= (($style) ? 'style="' . $style . '" ' : '') . 'alt="' . htmlentities(($alt) ? $alt : t('Image/photo'),ENT_COMPAT,'UTF-8') . '" '; + $style .= 'max-width: 100%;'; + + $output .= 'style="' . $style . '" '; + $output .= 'alt="' . htmlentities(($alt ? $alt : t('Image/photo')), ENT_COMPAT, 'UTF-8') . '" '; + $output .= 'title="' . htmlentities($title, ENT_COMPAT, 'UTF-8') . '" '; + $output .= 'class="' . htmlentities($class, ENT_COMPAT, 'UTF-8') . '" '; - $output .= 'src="' . $match[4] . '" >'; + $output .= 'src="' . $match[4] . '" />'; return $output; |