aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-03-10 22:35:59 +0000
committerMario <mario@mariovavti.com>2024-03-10 22:35:59 +0000
commitee8aba3221f995b265c3196505a1c7c26b76f116 (patch)
tree2b32c6153b40da13d7ebd944fe8e7fd383785f32 /include
parent0a730935f52ae33bf6132a1ae522e88a37b0f5e6 (diff)
downloadvolse-hubzilla-ee8aba3221f995b265c3196505a1c7c26b76f116.tar.gz
volse-hubzilla-ee8aba3221f995b265c3196505a1c7c26b76f116.tar.bz2
volse-hubzilla-ee8aba3221f995b265c3196505a1c7c26b76f116.zip
implement sodium-plus library to replace unmaintained sjcl
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php38
1 files changed, 18 insertions, 20 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 848d117fb..b39822b05 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -247,41 +247,39 @@ function bb_parse_crypt($match) {
$matches = [];
$attributes = $match[1];
-
- $algorithm = "";
+ $hint = '';
+ $algorithm = '';
preg_match("/alg='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $algorithm = $matches[1];
-
- preg_match("/alg=\&quot\;(.*?)\&quot\;/ism", $attributes, $matches);
- if ($matches[1] != "")
- $algorithm = $matches[1];
+ $algorithm = $matches[1] ?? '';
- $hint = "";
+ if (!$algorithm) {
+ preg_match("/alg=\&quot\;(.*?)\&quot\;/ism", $attributes, $matches);
+ $algorithm = $matches[1] ?? '';
+ }
preg_match("/hint='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $hint = $matches[1];
- preg_match("/hint=\&quot\;(.*?)\&quot\;/ism", $attributes, $matches);
- if ($matches[1] != "")
- $hint = $matches[1];
+ $hint = $matches[1] ?? '';
+
+ if (!$hint) {
+ preg_match("/hint=\&quot\;(.*?)\&quot\;/ism", $attributes, $matches);
+ $hint = $matches[1] ?? '';
+ }
$x = random_string();
- $f = 'hz_decrypt';
+ $f = 'sodium_decrypt';
- //legacy cryptojs support
- if(plugin_is_installed('cryptojs')) {
- $f = ((in_array($algorithm, ['AES-128-CCM', 'rot13', 'triple-rot13'])) ? 'hz_decrypt' : 'red_decrypt');
+ if (in_array($algorithm, ['AES-128-CCM', 'rot13', 'triple-rot13'])) {
+ $f = 'hz_decrypt'; // deprecated
}
$onclick = 'onclick="' . $f . '(\'' . $algorithm . '\',\'' . $hint . '\',\'' . $match[2] . '\',\'#' . $x . '\');"';
$label = t('Encrypted content');
- $Text = '<br /><div id="' . $x . '"><img class="cursor-pointer" src="' . z_root() . '/images/lock_icon.svg" ' . $onclick . ' alt="' . $label . '" title="' . $label . '" /></div><br />';
+ $text = '<br /><div id="' . $x . '"><img class="cursor-pointer" src="' . z_root() . '/images/lock_icon.svg" ' . $onclick . ' alt="' . $label . '" title="' . $label . '" /></div><br />';
- return $Text;
+ return $text;
}
/**