aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/acl_selectors.php2
-rw-r--r--include/crypto.php155
-rw-r--r--include/items.php6
-rw-r--r--include/markdown.php12
4 files changed, 16 insertions, 159 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index f0e0140dc..139a913b2 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -181,7 +181,7 @@ function get_post_aclDialogDescription() {
$description = t('Post permissions %s cannot be changed %s after a post is shared.</br />These permissions set who is allowed to view the post.');
// Lets keep the emphasis styling seperate from the translation. It may change.
- $emphasisOpen = '<b><a href="' . z_root() . '/help/acl_dialog_post" target="hubzilla-help">';
+ $emphasisOpen = '<b><a href="' . z_root() . '/help/member/permissions" target="hubzilla-help">';
$emphasisClose = '</a></b>';
return sprintf($description, $emphasisOpen, $emphasisClose);
diff --git a/include/crypto.php b/include/crypto.php
index 4d50310fb..4292bdb4d 100644
--- a/include/crypto.php
+++ b/include/crypto.php
@@ -2,9 +2,6 @@
use Zotlabs\Lib\Config;
-require_once('library/ASNValue.class.php');
-require_once('library/asn1.php');
-
function rsa_sign($data,$key,$alg = 'sha256') {
if(! $key)
return 'no key';
@@ -309,158 +306,6 @@ function new_keypair($bits) {
}
-function DerToPem($Der, $Private=false)
-{
- //Encode:
- $Der = base64_encode($Der);
- //Split lines:
- $lines = str_split($Der, 65);
- $body = implode("\n", $lines);
- //Get title:
- $title = $Private? 'RSA PRIVATE KEY' : 'PUBLIC KEY';
- //Add wrapping:
- $result = "-----BEGIN {$title}-----\n";
- $result .= $body . "\n";
- $result .= "-----END {$title}-----\n";
-
- return $result;
-}
-
-function DerToRsa($Der)
-{
- //Encode:
- $Der = base64_encode($Der);
- //Split lines:
- $lines = str_split($Der, 64);
- $body = implode("\n", $lines);
- //Get title:
- $title = 'RSA PUBLIC KEY';
- //Add wrapping:
- $result = "-----BEGIN {$title}-----\n";
- $result .= $body . "\n";
- $result .= "-----END {$title}-----\n";
-
- return $result;
-}
-
-
-function pkcs8_encode($Modulus,$PublicExponent) {
- //Encode key sequence
- $modulus = new ASNValue(ASNValue::TAG_INTEGER);
- $modulus->SetIntBuffer($Modulus);
- $publicExponent = new ASNValue(ASNValue::TAG_INTEGER);
- $publicExponent->SetIntBuffer($PublicExponent);
- $keySequenceItems = array($modulus, $publicExponent);
- $keySequence = new ASNValue(ASNValue::TAG_SEQUENCE);
- $keySequence->SetSequence($keySequenceItems);
- //Encode bit string
- $bitStringValue = $keySequence->Encode();
- $bitStringValue = chr(0x00) . $bitStringValue; //Add unused bits byte
- $bitString = new ASNValue(ASNValue::TAG_BITSTRING);
- $bitString->Value = $bitStringValue;
- //Encode body
- $bodyValue = "\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00" . $bitString->Encode();
- $body = new ASNValue(ASNValue::TAG_SEQUENCE);
- $body->Value = $bodyValue;
- //Get DER encoded public key:
- $PublicDER = $body->Encode();
- return $PublicDER;
-}
-
-
-function pkcs1_encode($Modulus,$PublicExponent) {
- //Encode key sequence
- $modulus = new ASNValue(ASNValue::TAG_INTEGER);
- $modulus->SetIntBuffer($Modulus);
- $publicExponent = new ASNValue(ASNValue::TAG_INTEGER);
- $publicExponent->SetIntBuffer($PublicExponent);
- $keySequenceItems = array($modulus, $publicExponent);
- $keySequence = new ASNValue(ASNValue::TAG_SEQUENCE);
- $keySequence->SetSequence($keySequenceItems);
- //Encode bit string
- $bitStringValue = $keySequence->Encode();
- return $bitStringValue;
-}
-
-
-// http://stackoverflow.com/questions/27568570/how-to-convert-raw-modulus-exponent-to-rsa-public-key-pem-format
-function metopem($m,$e) {
- $der = pkcs8_encode($m,$e);
- $key = DerToPem($der,false);
- return $key;
-}
-
-
-function pubrsatome($key,&$m,&$e) {
- require_once('library/asn1.php');
-
- $lines = explode("\n",$key);
- unset($lines[0]);
- unset($lines[count($lines)]);
- $x = base64_decode(implode('',$lines));
-
- $r = ASN_BASE::parseASNString($x);
-
- $m = base64url_decode($r[0]->asnData[0]->asnData);
- $e = base64url_decode($r[0]->asnData[1]->asnData);
-}
-
-
-function rsatopem($key) {
- pubrsatome($key,$m,$e);
- return(metopem($m,$e));
-}
-
-function pemtorsa($key) {
- pemtome($key,$m,$e);
- return(metorsa($m,$e));
-}
-
-function pemtome($key,&$m,&$e) {
- $lines = explode("\n",$key);
- unset($lines[0]);
- unset($lines[count($lines)]);
- $x = base64_decode(implode('',$lines));
-
- $r = ASN_BASE::parseASNString($x);
-
- $m = base64url_decode($r[0]->asnData[1]->asnData[0]->asnData[0]->asnData);
- $e = base64url_decode($r[0]->asnData[1]->asnData[0]->asnData[1]->asnData);
-}
-
-function metorsa($m,$e) {
- $der = pkcs1_encode($m,$e);
- $key = DerToRsa($der);
- return $key;
-}
-
-
-
-function salmon_key($pubkey) {
- pemtome($pubkey,$m,$e);
- return 'RSA' . '.' . base64url_encode($m,true) . '.' . base64url_encode($e,true) ;
-}
-
-
-function convert_salmon_key($key) {
-
- if(strstr($key,','))
- $rawkey = substr($key,strpos($key,',')+1);
- else
- $rawkey = substr($key,5);
-
- $key_info = explode('.',$rawkey);
-
- $m = base64url_decode($key_info[1]);
- $e = base64url_decode($key_info[2]);
-
- logger('key details: ' . print_r($key_info,true), LOGGER_DATA);
- $salmon_key = metopem($m,$e);
- return $salmon_key;
-
-}
-
-
function z_obscure($s) {
return json_encode(crypto_encapsulate($s,Config::Get('system','pubkey')));
}
diff --git a/include/items.php b/include/items.php
index b80c5672b..339a61753 100644
--- a/include/items.php
+++ b/include/items.php
@@ -5426,7 +5426,7 @@ function items_by_parent_ids(array $parents, null|array $thr_parents = null, str
$thr_parent_sql = " AND item.thr_parent IN (" . protect_sprintf($thr_parent_str) . ") ";
}
- $reaction = item_reaction_sql($ids, $permission_sql, 'final_selection');
+ $reaction = item_reaction_sql($ids, $permission_sql, 'final_selection', $blog_mode);
$reaction_cte_sql = $reaction['cte'];
$reaction_select_sql = $reaction['select'];
$reaction_join_sql = $reaction['join'];
@@ -5506,7 +5506,7 @@ function items_by_parent_ids(array $parents, null|array $thr_parents = null, str
* @param string $join_prefix (optional) - prefix for the join part defaults to 'item'
*/
-function item_reaction_sql(string $ids, string $permission_sql = '', string $join_prefix = 'item'): array
+function item_reaction_sql(string $ids, string $permission_sql = '', string $join_prefix = 'item', bool $blog_mode = false): array
{
$item_normal_sql = item_normal();
$observer = get_observer_hash();
@@ -5522,7 +5522,7 @@ function item_reaction_sql(string $ids, string $permission_sql = '', string $joi
$thread_allow = ((local_channel()) ? PConfig::Get(local_channel(), 'system', 'thread_allow', true) : Config::Get('system', 'thread_allow', true));
- if ($thread_allow) {
+ if ($thread_allow || $blog_mode) {
$verbs['comment'] = ['Create', 'Update', 'EmojiReact'];
}
diff --git a/include/markdown.php b/include/markdown.php
index 90d671fe4..d2379e7ed 100644
--- a/include/markdown.php
+++ b/include/markdown.php
@@ -64,6 +64,12 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) {
// Escaping the hash tags
$s = preg_replace('/\#([^\s\#])/','&#35;$1',$s);
+ // Protect mentions from being mangled by the markdown parser
+ $s = preg_replace_callback(
+ '|@\{([^}]+)\}|',
+ fn ($matches) => '@{' . base64_encode($matches[1]) . '}',
+ $s);
+
$s = MarkdownExtra::defaultTransform($s);
@@ -76,6 +82,12 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) {
$s = str_replace("\r","",$s);
}
+ // Restore mentions after markdown conversion
+ $s = preg_replace_callback(
+ '|@\{([^}]+)\}|',
+ fn ($matches) => '@{' . base64_decode($matches[1]) . '}',
+ $s);
+
$s = str_replace('&#35;','#',$s);
$s = html2bbcode($s);