From 49e62f22ad750d4d60936ec8437caee91809b179 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 22 Dec 2015 10:24:31 +0100 Subject: QRCode plugin: use url instead of real_url Fixes #414 and avoid usage of redirector in QRCode. Also fixed a bug with URL encoding. --- application/LinkDB.php | 4 +++- plugins/qrcode/qrcode.php | 6 +++++- tests/plugins/PlugQrcodeTest.php | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/application/LinkDB.php b/application/LinkDB.php index f771ac8b..51fa926d 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -17,8 +17,10 @@ * - private: Is this link private? 0=no, other value=yes * - tags: tags attached to this entry (separated by spaces) * - title Title of the link - * - url URL of the link. Can be absolute or relative. + * - url URL of the link. Used for displayable links (no redirector, relative, etc.). + * Can be absolute or relative. * Relative URLs are permalinks (e.g.'?m-ukcw') + * - real_url Absolute processed URL. * * Implements 3 interfaces: * - ArrayAccess: behaves like an associative array; diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index 5f6e76a2..84a19618 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php @@ -17,7 +17,11 @@ function hook_qrcode_render_linklist($data) $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); foreach ($data['links'] as &$value) { - $qrcode = sprintf($qrcode_html, $value['real_url'], $value['real_url'], PluginManager::$PLUGINS_PATH); + $qrcode = sprintf($qrcode_html, + urlencode($value['url']), + $value['url'], + PluginManager::$PLUGINS_PATH + ); $value['link_plugin'][] = $qrcode; } diff --git a/tests/plugins/PlugQrcodeTest.php b/tests/plugins/PlugQrcodeTest.php index c749fa86..86dc7f29 100644 --- a/tests/plugins/PlugQrcodeTest.php +++ b/tests/plugins/PlugQrcodeTest.php @@ -30,7 +30,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase 'title' => $str, 'links' => array( array( - 'real_url' => $str, + 'url' => $str, ) ) ); @@ -39,7 +39,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase $link = $data['links'][0]; // data shouldn't be altered $this->assertEquals($str, $data['title']); - $this->assertEquals($str, $link['real_url']); + $this->assertEquals($str, $link['url']); // plugin data $this->assertEquals(1, count($link['link_plugin'])); -- cgit v1.2.3