diff options
Diffstat (limited to 'application/LinkDB.php')
-rw-r--r-- | application/LinkDB.php | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php index 4c1a45b5..b1072e07 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php | |||
@@ -66,21 +66,39 @@ class LinkDB implements Iterator, Countable, ArrayAccess | |||
66 | private $_redirector; | 66 | private $_redirector; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Set this to `true` to urlencode link behind redirector link, `false` to leave it untouched. | ||
70 | * | ||
71 | * Example: | ||
72 | * anonym.to needs clean URL while dereferer.org needs urlencoded URL. | ||
73 | * | ||
74 | * @var boolean $redirectorEncode parameter: true or false | ||
75 | */ | ||
76 | private $redirectorEncode; | ||
77 | |||
78 | /** | ||
69 | * Creates a new LinkDB | 79 | * Creates a new LinkDB |
70 | * | 80 | * |
71 | * Checks if the datastore exists; else, attempts to create a dummy one. | 81 | * Checks if the datastore exists; else, attempts to create a dummy one. |
72 | * | 82 | * |
73 | * @param string $datastore datastore file path. | 83 | * @param string $datastore datastore file path. |
74 | * @param boolean $isLoggedIn is the user logged in? | 84 | * @param boolean $isLoggedIn is the user logged in? |
75 | * @param boolean $hidePublicLinks if true all links are private. | 85 | * @param boolean $hidePublicLinks if true all links are private. |
76 | * @param string $redirector link redirector set in user settings. | 86 | * @param string $redirector link redirector set in user settings. |
87 | * @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true). | ||
77 | */ | 88 | */ |
78 | function __construct($datastore, $isLoggedIn, $hidePublicLinks, $redirector = '') | 89 | function __construct( |
90 | $datastore, | ||
91 | $isLoggedIn, | ||
92 | $hidePublicLinks, | ||
93 | $redirector = '', | ||
94 | $redirectorEncode = true | ||
95 | ) | ||
79 | { | 96 | { |
80 | $this->_datastore = $datastore; | 97 | $this->_datastore = $datastore; |
81 | $this->_loggedIn = $isLoggedIn; | 98 | $this->_loggedIn = $isLoggedIn; |
82 | $this->_hidePublicLinks = $hidePublicLinks; | 99 | $this->_hidePublicLinks = $hidePublicLinks; |
83 | $this->_redirector = $redirector; | 100 | $this->_redirector = $redirector; |
101 | $this->redirectorEncode = $redirectorEncode === true; | ||
84 | $this->_checkDB(); | 102 | $this->_checkDB(); |
85 | $this->_readDB(); | 103 | $this->_readDB(); |
86 | } | 104 | } |
@@ -278,7 +296,12 @@ You use the community supported version of the original Shaarli project, by Seba | |||
278 | 296 | ||
279 | // Do not use the redirector for internal links (Shaarli note URL starting with a '?'). | 297 | // Do not use the redirector for internal links (Shaarli note URL starting with a '?'). |
280 | if (!empty($this->_redirector) && !startsWith($link['url'], '?')) { | 298 | if (!empty($this->_redirector) && !startsWith($link['url'], '?')) { |
281 | $link['real_url'] = $this->_redirector . urlencode($link['url']); | 299 | $link['real_url'] = $this->_redirector; |
300 | if ($this->redirectorEncode) { | ||
301 | $link['real_url'] .= urlencode(unescape($link['url'])); | ||
302 | } else { | ||
303 | $link['real_url'] .= $link['url']; | ||
304 | } | ||
282 | } | 305 | } |
283 | else { | 306 | else { |
284 | $link['real_url'] = $link['url']; | 307 | $link['real_url'] = $link['url']; |