diff options
author | Mario <mario@mariovavti.com> | 2021-02-18 09:36:22 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-02-18 09:36:22 +0000 |
commit | 92f3c5ae2191dbffcc327dd1068e692467dc24dd (patch) | |
tree | 72cefec7d6d1392d6871bb0f3e8cc204acc94636 /include | |
parent | c3ec5d4d6ac48988b70d17b0b08b35da92cfa24f (diff) | |
download | volse-hubzilla-92f3c5ae2191dbffcc327dd1068e692467dc24dd.tar.gz volse-hubzilla-92f3c5ae2191dbffcc327dd1068e692467dc24dd.tar.bz2 volse-hubzilla-92f3c5ae2191dbffcc327dd1068e692467dc24dd.zip |
backward compatibility with recent crypto changes
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 66 | ||||
-rw-r--r-- | include/zot.php | 3 |
2 files changed, 36 insertions, 33 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 6bb33671e..2832a7627 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -80,7 +80,7 @@ function tryoembed($match) { return $match[0]; $html = oembed_format_object($o); - return $html; + return $html; } @@ -92,7 +92,7 @@ function nakedoembed($match) { // this function no longer performs oembed on naked links // because they author may have created naked links intentionally. // Now it just strips zids on naked links. - + return str_replace($url,$strip_url,$match[0]); } @@ -283,7 +283,7 @@ function bb_svg($match) { $params = str_replace(['<br>', '"'], [ '', '"'],$match[1]); $Text = str_replace([ '[',']' ], [ '<','>' ], $match[2]); - + $output = '<svg' . (($params) ? $params : ' width="100%" height="480" ') . '>' . str_replace(['<br>', '"', ' '], [ '', '"', ' '],$Text) . '</svg>'; $purify = new SvgSanitizer(); @@ -641,24 +641,24 @@ function bb_definitionList($match) { // The bbcode transformation will be: // [*=term-text] description-text => </dd> <dt>term-text<dt><dd> description-text - // then after all replacements have been made, the extra </dd> at the start of the + // then after all replacements have been made, the extra </dd> at the start of the // first line can be removed. HTML5 allows the tag to be missing from the end of the last line. // Using '(?<!\\\)' to allow backslash-escaped closing braces to appear in the term-text. $closeDescriptionTag = "</dd>\n"; $eatLeadingSpaces = '(?: |[ \t])*'; // prevent spaces infront of [*= from adding another line to the previous element $listElements = preg_replace('/^(\n|<br \/>)/', '', $match[2]); // ltrim the first newline $listElements = preg_replace( - '/' . $eatLeadingSpaces . '\[\*=([[:print:]]*?)(?<!\\\)\]/uism', - $closeDescriptionTag . '<dt>$1</dt><dd>', + '/' . $eatLeadingSpaces . '\[\*=([[:print:]]*?)(?<!\\\)\]/uism', + $closeDescriptionTag . '<dt>$1</dt><dd>', $listElements ); // Unescape any \] inside the <dt> tags $listElements = preg_replace_callback('/<dt>(.*?)<\/dt>/ism', 'bb_definitionList_unescapeBraces', $listElements); - + // Remove the extra </dd> at the start of the string, if there is one. $firstOpenTag = strpos($listElements, '<dd>'); $firstCloseTag = strpos($listElements, $closeDescriptionTag); - if ($firstCloseTag !== false && ($firstOpenTag === false || ($firstCloseTag < $firstOpenTag))) { + if ($firstCloseTag !== false && ($firstOpenTag === false || ($firstCloseTag < $firstOpenTag))) { $listElements = preg_replace( '/<\/dd>/ism', '', $listElements, 1); } @@ -802,7 +802,7 @@ function bb_imgoptions($match) { // $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); // alt text cannot contain ']' - + // [img|zmg=wwwxhhh float=left|right alt=alt text]url[/img|zmg] $local_match = null; @@ -818,7 +818,7 @@ function bb_imgoptions($match) { if ($x) { $alt = $matches[1]; } - + $x = preg_match("/alt=\"\;(.*?)\"\;/ism", $attributes, $matches); if ($x) { $alt = $matches[1]; @@ -828,7 +828,7 @@ function bb_imgoptions($match) { if ($x) { $width = $matches[1]; } - + $x = preg_match("/width=\"\;(.*?)\"\;/ism", $attributes, $matches); if ($x) { $width = $matches[1]; @@ -838,7 +838,7 @@ function bb_imgoptions($match) { if ($x) { $height = $matches[1]; } - + $x = preg_match("/height=\"\;(.*?)\"\;/ism", $attributes, $matches); if ($x) { $height = $matches[1]; @@ -848,14 +848,14 @@ function bb_imgoptions($match) { if ($x) { $style = $matches[1]; } - + $x = preg_match("/style=\"\;(.*?)\"\;/ism", $attributes, $matches); if ($x) { $style = $matches[1]; } // legacy img options - + if ($match[2] === '=') { // pull out (optional) legacy size declarations first if (preg_match("/([0-9]*)x([0-9]*)/ism",$match[3],$local_match)) { @@ -873,16 +873,16 @@ function bb_imgoptions($match) { $float = 'right'; $match[3] = substr($match[3],$n + 11); } - + // finally alt text which extends to the close of the tag if ((! $alt) && ($n = strpos($match[3],'alt=') !== false)) { $alt = substr($match[3],$n + 4); } // now assemble the resulting img tag from these components - + $output = '<img ' . (($match[1] === 'z') ? 'class="zrl" loading="eager"' : '') . ' '; - + if ($width) { $style .= 'width: 100%; max-width: ' . $width . 'px; '; } @@ -892,13 +892,13 @@ function bb_imgoptions($match) { if ($float) { $style .= 'float: ' . $float . '; '; } - + $output .= (($style) ? 'style="' . $style . '" ' : '') . 'alt="' . htmlentities(($alt) ? $alt : t('Image/photo'),ENT_COMPAT,'UTF-8') . '" '; $output .= 'src="' . $match[4] . '" >'; - + return $output; - + } function bb_code_protect($s) { @@ -935,7 +935,7 @@ function bb_code_options($match) { } if($pre) { return '<pre><code class="'. $class .'" style="'. $style .'">' . bb_code_protect(trim($match[2])) . '</code></pre>'; - } else { + } else { return '<code class="'. $class .'" style="'. $style .'">' . bb_code_protect(trim($match[2])) . '</code>'; } } @@ -949,7 +949,7 @@ function bb_fixtable_lf($match) { // remove extraneous whitespace between table element tags since newlines will all // be converted to '<br />' and turn your neatly crafted tables into a whole lot of // empty space. - + $x = preg_replace("/\]\s+\[/",'][',$match[1]); return '[table]' . $x . '[/table]'; @@ -991,7 +991,7 @@ function parseIdentityAwareHTML($Text) { } if (strpos($Text,'[pre]') !== false) { $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text); - } + } // process [observer] tags before we do anything else because we might // be stripping away stuff that then doesn't need to be worked on anymore @@ -1012,7 +1012,7 @@ function parseIdentityAwareHTML($Text) { $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text); $Text = preg_replace("/\[rpost(=.*?)?\](.*?)\[\/rpost\]/ism", '', $Text); } - } + } // replace [observer.baseurl] if ($observer) { $s1 = '<span class="bb_observer" title="' . t('Different viewers will see this text differently') . '">'; @@ -1033,11 +1033,11 @@ function parseIdentityAwareHTML($Text) { $Text = str_replace('[observer.webname]','',$Text); $Text = str_replace('[observer.photo]','', $Text); } - + $Text = str_replace(array('[baseurl]','[sitename]'),array(z_root(),get_config('system','sitename')),$Text); - - // Unhide all [noparse] contained bbtags unspacefying them + + // Unhide all [noparse] contained bbtags unspacefying them // and triming the [noparse] tag. if (strpos($Text,'[noparse]') !== false) { $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_unspacefy_and_trim', $Text); @@ -1251,7 +1251,7 @@ function bbcode($Text, $options = []) { $Text = preg_replace("/\[map\]/", '<div class="map"></div>', $Text); } } - + // Check for bold text if (strpos($Text,'[b]') !== false) { $Text = preg_replace("(\[b\](.*?)\[\/b\])ism", '<strong>$1</strong>', $Text); @@ -1377,8 +1377,8 @@ function bbcode($Text, $options = []) { $Text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '<li>$1</li>', $Text); // [dl] tags have an optional [dl terms="bi"] form where bold/italic/underline/mono/large - // etc. style may be specified for the "terms" in the definition list. The quotation marks - // are also optional. The regex looks intimidating, but breaks down as: + // etc. style may be specified for the "terms" in the definition list. The quotation marks + // are also optional. The regex looks intimidating, but breaks down as: // "[dl" <optional-whitespace> <optional-termStyles> "]" <matchGroup2> "[/dl]" // where optional-termStyles are: "terms=" <optional-quote> <matchGroup1> <optional-quote> $Text = preg_replace_callback('/\[dl[[:space:]]*(?:terms=(?:"|")?([a-zA-Z]+)(?:"|")?)?\](.*?)\[\/dl\]/ism', 'bb_definitionList', $Text); @@ -1564,7 +1564,7 @@ function bbcode($Text, $options = []) { // If we found an event earlier, strip out all the event code and replace with a reformatted version. // Replace the event-start section with the entire formatted event. The other bbcode is stripped. - // Summary (e.g. title) is required, earlier revisions only required description (in addition to + // Summary (e.g. title) is required, earlier revisions only required description (in addition to // start which is always required). Allow desc with a missing summary for compatibility. if ((x($ev,'desc') || x($ev,'summary')) && x($ev,'dtstart')) { @@ -1573,7 +1573,7 @@ function bbcode($Text, $options = []) { $sub = str_replace('$',"\0",$sub); - $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text); + $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text); $Text = preg_replace("/\[event\](.*?)\[\/event\]/ism",'',$Text); $Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text); @@ -1588,7 +1588,7 @@ function bbcode($Text, $options = []) { } - // Unhide all [noparse] contained bbtags unspacefying them + // Unhide all [noparse] contained bbtags unspacefying them // and triming the [noparse] tag. if (strpos($Text,'[noparse]') !== false) { $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_unspacefy_and_trim', $Text); diff --git a/include/zot.php b/include/zot.php index 84bf3f9b2..634561fa3 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1131,6 +1131,7 @@ function zot_process_response($hub, $arr, $outq) { if(is_array($x) && array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) { if(array_key_exists('iv',$x['delivery_report'])) { + $x['delivery_report']['encrypted'] = true; $j = Crypto::unencapsulate($x['delivery_report'],get_config('system','prvkey')); if($j) { $x['delivery_report'] = json_decode($j,true); @@ -1317,6 +1318,7 @@ function zot_import($arr, $sender_url) { } if(array_key_exists('iv', $data)) { + $data['encrypted'] = true; $data = json_decode(Crypto::unencapsulate($data,get_config('system','prvkey')),true); } @@ -1345,6 +1347,7 @@ function zot_import($arr, $sender_url) { $result = null; if(array_key_exists('iv',$i['notify'])) { + $i['notify']['encrypted'] = true; $i['notify'] = json_decode(Crypto::unencapsulate($i['notify'],get_config('system','prvkey')),true); } |