]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
QRCode plugin: use url instead of real_url 418/head
authorArthurHoaro <arthur@hoa.ro>
Tue, 22 Dec 2015 09:24:31 +0000 (10:24 +0100)
committerArthurHoaro <arthur@hoa.ro>
Tue, 22 Dec 2015 09:59:41 +0000 (10:59 +0100)
Fixes #414 and avoid usage of redirector in QRCode.

Also fixed a bug with URL encoding.

application/LinkDB.php
plugins/qrcode/qrcode.php
tests/plugins/PlugQrcodeTest.php

index f771ac8bf7b1677c99c67ac468ea33009c69a6cc..51fa926df328b19646053c3741b836db1eb3727e 100644 (file)
  *  - 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;
index 5f6e76a2f8c42d035f0c7026158b463935d953b0..84a1961888667833fe3f84cdaa3943bcf192bd11 100644 (file)
@@ -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;
     }
 
index c749fa86f6a49aa167bb4c8c7761a2ce32b38f8c..86dc7f293059a94830f0cbec3f0f7cc74229becc 100644 (file)
@@ -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']));