diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/FeedBuilder.php | 2 | ||||
-rw-r--r-- | application/LinkUtils.php | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/application/FeedBuilder.php b/application/FeedBuilder.php index 3cfaafb4..ebae18b4 100644 --- a/application/FeedBuilder.php +++ b/application/FeedBuilder.php | |||
@@ -152,7 +152,7 @@ class FeedBuilder | |||
152 | } else { | 152 | } else { |
153 | $permalink = '<a href="'. $link['guid'] .'" title="'. t('Permalink') .'">'. t('Permalink') .'</a>'; | 153 | $permalink = '<a href="'. $link['guid'] .'" title="'. t('Permalink') .'">'. t('Permalink') .'</a>'; |
154 | } | 154 | } |
155 | $link['description'] = format_description($link['description'], '', $pageaddr); | 155 | $link['description'] = format_description($link['description'], '', false, $pageaddr); |
156 | $link['description'] .= PHP_EOL .'<br>— '. $permalink; | 156 | $link['description'] .= PHP_EOL .'<br>— '. $permalink; |
157 | 157 | ||
158 | $pubDate = $link['created']; | 158 | $pubDate = $link['created']; |
diff --git a/application/LinkUtils.php b/application/LinkUtils.php index 267e62cd..e3d95d08 100644 --- a/application/LinkUtils.php +++ b/application/LinkUtils.php | |||
@@ -102,12 +102,13 @@ function count_private($links) | |||
102 | * | 102 | * |
103 | * @param string $text input string. | 103 | * @param string $text input string. |
104 | * @param string $redirector if a redirector is set, use it to gerenate links. | 104 | * @param string $redirector if a redirector is set, use it to gerenate links. |
105 | * @param bool $urlEncode Use `urlencode()` on the URL after the redirector or not. | ||
105 | * | 106 | * |
106 | * @return string returns $text with all links converted to HTML links. | 107 | * @return string returns $text with all links converted to HTML links. |
107 | * | 108 | * |
108 | * @see Function inspired from http://www.php.net/manual/en/function.preg-replace.php#85722 | 109 | * @see Function inspired from http://www.php.net/manual/en/function.preg-replace.php#85722 |
109 | */ | 110 | */ |
110 | function text2clickable($text, $redirector = '') | 111 | function text2clickable($text, $redirector = '', $urlEncode = true) |
111 | { | 112 | { |
112 | $regex = '!(((?:https?|ftp|file)://|apt:|magnet:)\S+[a-z0-9\(\)]/?)!si'; | 113 | $regex = '!(((?:https?|ftp|file)://|apt:|magnet:)\S+[a-z0-9\(\)]/?)!si'; |
113 | 114 | ||
@@ -117,8 +118,9 @@ function text2clickable($text, $redirector = '') | |||
117 | // Redirector is set, urlencode the final URL. | 118 | // Redirector is set, urlencode the final URL. |
118 | return preg_replace_callback( | 119 | return preg_replace_callback( |
119 | $regex, | 120 | $regex, |
120 | function ($matches) use ($redirector) { | 121 | function ($matches) use ($redirector, $urlEncode) { |
121 | return '<a href="' . $redirector . urlencode($matches[1]) .'">'. $matches[1] .'</a>'; | 122 | $url = $urlEncode ? urlencode($matches[1]) : $matches[1]; |
123 | return '<a href="' . $redirector . $url .'">'. $matches[1] .'</a>'; | ||
122 | }, | 124 | }, |
123 | $text | 125 | $text |
124 | ); | 126 | ); |
@@ -164,12 +166,13 @@ function space2nbsp($text) | |||
164 | * | 166 | * |
165 | * @param string $description shaare's description. | 167 | * @param string $description shaare's description. |
166 | * @param string $redirector if a redirector is set, use it to gerenate links. | 168 | * @param string $redirector if a redirector is set, use it to gerenate links. |
169 | * @param bool $urlEncode Use `urlencode()` on the URL after the redirector or not. | ||
167 | * @param string $indexUrl URL to Shaarli's index. | 170 | * @param string $indexUrl URL to Shaarli's index. |
168 | * | 171 | |
169 | * @return string formatted description. | 172 | * @return string formatted description. |
170 | */ | 173 | */ |
171 | function format_description($description, $redirector = '', $indexUrl = '') { | 174 | function format_description($description, $redirector = '', $urlEncode = true, $indexUrl = '') { |
172 | return nl2br(space2nbsp(hashtag_autolink(text2clickable($description, $redirector), $indexUrl))); | 175 | return nl2br(space2nbsp(hashtag_autolink(text2clickable($description, $redirector, $urlEncode), $indexUrl))); |
173 | } | 176 | } |
174 | 177 | ||
175 | /** | 178 | /** |