add gen_link_id() function to selectively encode/decode the message-id component of /display/ links for message-ids that contain troublesome characters

This commit is contained in:
Hubzilla
2017-01-19 15:37:30 -08:00
parent 5ce96b9b95
commit 96f196febd
10 changed files with 31 additions and 18 deletions

View File

@@ -30,12 +30,10 @@ class Display extends \Zotlabs\Web\Controller {
if(argc() > 1 && argv(1) !== 'load')
$item_hash = argv(1);
if($_REQUEST['mid'])
$item_hash = $_REQUEST['mid'];
if(! $item_hash) {
if(! $item_hash) {
\App::$error = 404;
notice( t('Item not found.') . EOL);
return;
@@ -93,9 +91,15 @@ class Display extends \Zotlabs\Web\Controller {
// find a copy of the item somewhere
$target_item = null;
if(strpos($item_hash,'b64.') === 0)
$decoded = @base64url_decode(substr($item_hash,4));
if($decoded)
$item_hash = $decoded;
$r = q("select id, uid, mid, parent_mid, item_type, item_deleted from item where mid like '%s' limit 1",
dbesc($item_hash . '%')
dbesc($item_hash . '%'),
dbesc($decoded . '%')
);
if($r) {