aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/Url.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/application/Url.php b/application/Url.php
index a4ac2e73..af38c4d9 100644
--- a/application/Url.php
+++ b/application/Url.php
@@ -118,7 +118,8 @@ class Url
118 */ 118 */
119 public function __construct($url) 119 public function __construct($url)
120 { 120 {
121 $this->parts = parse_url(trim($url)); 121 $url = self::cleanupUnparsedUrl(trim($url));
122 $this->parts = parse_url($url);
122 123
123 if (!empty($url) && empty($this->parts['scheme'])) { 124 if (!empty($url) && empty($this->parts['scheme'])) {
124 $this->parts['scheme'] = 'http'; 125 $this->parts['scheme'] = 'http';
@@ -126,6 +127,35 @@ class Url
126 } 127 }
127 128
128 /** 129 /**
130 * Clean up URL before it's parsed.
131 * ie. handle urlencode, url prefixes, etc.
132 *
133 * @param string $url URL to clean.
134 *
135 * @return string cleaned URL.
136 */
137 protected static function cleanupUnparsedUrl($url)
138 {
139 return self::removeFirefoxAboutReader($url);
140 }
141
142 /**
143 * Remove Firefox Reader prefix if it's present.
144 *
145 * @param string $input url
146 *
147 * @return string cleaned url
148 */
149 protected static function removeFirefoxAboutReader($input)
150 {
151 $firefoxPrefix = 'about://reader?url=';
152 if (startsWith($input, $firefoxPrefix)) {
153 return urldecode(ltrim($input, $firefoxPrefix));
154 }
155 return $input;
156 }
157
158 /**
129 * Returns a string representation of this URL 159 * Returns a string representation of this URL
130 */ 160 */
131 public function toString() 161 public function toString()