diff options
author | friendica <info@friendica.com> | 2013-11-07 20:18:52 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-11-07 20:18:52 -0800 |
commit | fc317172d5c6632df50aa8e25509ee2b6b830d2f (patch) | |
tree | be7df22d9bb95202d9b5b05fd3bdfc28d05c3610 | |
parent | cb37c0ce1421ecf5ddd00baee39b227307bb10b5 (diff) | |
download | volse-hubzilla-fc317172d5c6632df50aa8e25509ee2b6b830d2f.tar.gz volse-hubzilla-fc317172d5c6632df50aa8e25509ee2b6b830d2f.tar.bz2 volse-hubzilla-fc317172d5c6632df50aa8e25509ee2b6b830d2f.zip |
more e2ee infrastructure - at this point if somebody wants it they're going to have to work for it.
-rw-r--r-- | include/bbcode.php | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 9ca8e3f03..14d0ce14a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -99,6 +99,43 @@ function bb_replace_images($body, $images) { }} + +function bb_parse_crypt($match) { + + $attributes = $match[1]; + + $algorithm = ""; + preg_match("/alg='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $algorithm = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); + + preg_match("/alg=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($matches[1] != "") + $algorithm = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); + + $hint = ""; + preg_match("/hint='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $hint = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); + preg_match("/hint=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($matches[1] != "") + $hint = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); + + // Next we really should link to a JS routine based on the algorithm which prompts for a key + // something like zdecrypt_{algorithm}, which will be a no-op if the decryption algorithm is not present + // We can either pass the text or pass a message ID and let the decryption module call /viewsrc or something + // to get the text. The text might be large so the message ID might be preferable. But if we pass the + // text directly we won't have to do a network fetch; and can potentially display the results in a popup. + + + $Text = '<br/><img src="' . z_root() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />' . t('Algorithm: ') . $algorithm . '<br />' . t('Key hint: ') . $hint . '<br />'; + + return $Text; + +} + + + function bb_ShareAttributes($match) { $attributes = $match[1]; @@ -465,9 +502,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" alt="' . t('Image/photo') . '" />', $Text); } - if (strpos($Text,'[crypt]') !== false) { + if (strpos($Text,'[/crypt]') !== false) { $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text); - $Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text); + $Text = preg_replace_callback("/\[crypt (.*?)\](.*?)\[\/crypt\]/ism", 'bb_parse_crypt', $Text); } // Try to Oembed if ($tryoembed) { |