diff --git a/boot.php b/boot.php index 004ebf3ad..963128b44 100644 --- a/boot.php +++ b/boot.php @@ -1,6 +1,6 @@ ' . Map::byCoordinates(str_replace('/', ' ', $match[1])) . '', $match[0]); -} -function bb_map_location($match) { - // the extra space in the following line is intentional - return str_replace($match[0], '
%s', trim(bbcode($data["description"]))); - } - - if ($data["type"] == "link") { - $return .= sprintf('%s', $data['url'], parse_url($data['url'], PHP_URL_HOST)); - } - - if ($simplehtml != 4) { - $return .= '
' . trim($share[3]) . "
' . trim($share[3]) . "
$1
', $Text); - - // Check for bold text - $Text = preg_replace("(\[b\](.*?)\[\/b\])ism", '$1', $Text); - - // Check for Italics text - $Text = preg_replace("(\[i\](.*?)\[\/i\])ism", '$1', $Text); - - // Check for Underline text - $Text = preg_replace("(\[u\](.*?)\[\/u\])ism", '$1', $Text); - - // Check for strike-through text - $Text = preg_replace("(\[s\](.*?)\[\/s\])ism", '$1
';
- // Check for [code] text
- $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism", "$CodeLayout", $Text);
-
- // Declare the format for [spoiler] layout
- $SpoilerLayout = '$1'; - - // Check for [spoiler] text - // handle nested quotes - $endlessloop = 0; - while ((strpos($Text, "[/spoiler]") !== false) && (strpos($Text, "[spoiler]") !== false) && (++$endlessloop < 20)) { - $Text = preg_replace("/\[spoiler\](.*?)\[\/spoiler\]/ism", "$SpoilerLayout", $Text); - } - - // Check for [spoiler=Author] text - - $t_wrote = L10n::t('$1 wrote:'); - - // handle nested quotes - $endlessloop = 0; - while ((strpos($Text, "[/spoiler]")!== false) && (strpos($Text, "[spoiler=") !== false) && (++$endlessloop < 20)) { - $Text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism", - "
$2", - $Text); - } - - // Declare the format for [quote] layout - $QuoteLayout = '
$1'; - - // Check for [quote] text - // handle nested quotes - $endlessloop = 0; - while ((strpos($Text, "[/quote]") !== false) && (strpos($Text, "[quote]") !== false) && (++$endlessloop < 20)) { - $Text = preg_replace("/\[quote\](.*?)\[\/quote\]/ism", "$QuoteLayout", $Text); - } - - // Check for [quote=Author] text - - $t_wrote = L10n::t('$1 wrote:'); - - // handle nested quotes - $endlessloop = 0; - while ((strpos($Text, "[/quote]")!== false) && (strpos($Text, "[quote=") !== false) && (++$endlessloop < 20)) { - $Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism", - "
$2", - $Text); - } - - - // [img=widthxheight]image source[/img] - $Text = preg_replace_callback("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", 'bb_PictureCacheExt', $Text); - - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); - $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '', $Text); - - // Images - // [img]pathtoimage[/img] - $Text = preg_replace_callback("/\[img\](.*?)\[\/img\]/ism", 'bb_PictureCache', $Text); - - $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '', $Text); - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '', $Text); - - // Shared content - $Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism", - function ($match) use ($simplehtml) { - return bb_ShareAttributes($match, $simplehtml); - }, $Text); - - $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '
([^<]*)
(?! for Diaspora inline code blocks
- if ($simplehtml === 3) {
- $return = '' . $match[1] . '
';
- }
- return $return;
- }
- , $Text);
-
- // Unhide all [noparse] contained bbtags unspacefying them
- // and triming the [noparse] tag.
-
- $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_unspacefy_and_trim', $Text);
- $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_unspacefy_and_trim', $Text);
- $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_unspacefy_and_trim', $Text);
-
-
- $Text = preg_replace('/\[\&\;([#a-z0-9]+)\;\]/', '&$1;', $Text);
- $Text = preg_replace('/\&\#039\;/', '\'', $Text);
- $Text = preg_replace('/\"\;/', '"', $Text);
-
- // fix any escaped ampersands that may have been converted into links
- $Text = preg_replace('/\<([^>]*?)(src|href)=(.*?)\&\;(.*?)\>/ism', '<$1$2=$3&$4>', $Text);
-
- // sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails)
- static $allowed_src_protocols = ['http', 'redir', 'cid'];
- $Text = preg_replace('#<([^>]*?)(src)="(?!' . implode('|', $allowed_src_protocols) . ')(.*?)"(.*?)>#ism',
- '<$1$2=""$4 data-original-src="$3" class="invalid-src" title="' . L10n::t('Invalid source protocol') . '">', $Text);
-
- // sanitize href attributes (only whitelisted protocols URLs)
- // default value for backward compatibility
- $allowed_link_protocols = Config::get('system', 'allowed_link_protocols', ['ftp', 'mailto', 'gopher', 'cid']);
-
- // Always allowed protocol even if config isn't set or not including it
- $allowed_link_protocols[] = 'http';
- $allowed_link_protocols[] = 'redir/';
-
- $regex = '#<([^>]*?)(href)="(?!' . implode('|', $allowed_link_protocols) . ')(.*?)"(.*?)>#ism';
- $Text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . L10n::t('Invalid link protocol') . '">', $Text);
-
- if ($saved_image) {
- $Text = bb_replace_images($Text, $saved_image);
- }
-
- // Clean up the HTML by loading and saving the HTML with the DOM.
- // Bad structured html can break a whole page.
- // For performance reasons do it only with ativated item cache or at export.
- if (!$tryoembed || (get_itemcachepath() != "")) {
- $doc = new DOMDocument();
- $doc->preserveWhiteSpace = false;
-
- $Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8");
-
- $doctype = '';
- $encoding = '';
- @$doc->loadHTML($encoding.$doctype."".$Text."");
- $doc->encoding = 'UTF-8';
- $Text = $doc->saveHTML();
- $Text = str_replace(["", "", $doctype, $encoding], ["", "", "", ""], $Text);
-
- $Text = str_replace('
', '', $Text);
-
- //$Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
- }
-
- // Clean up some useless linebreaks in lists
- //$Text = str_replace('
', '
', $Text);
- //$Text = str_replace('
', '', $Text);
- //$Text = str_replace('
', ' ', $Text);
- //$Text = str_replace('