Index: trunk/phase3/includes/Title.php |
— | — | @@ -161,11 +161,12 @@ |
162 | 162 | * Create a new Title from URL-encoded text. Ensures that |
163 | 163 | * the given title's length does not exceed the maximum. |
164 | 164 | * @param string $url the title, as might be taken from a URL |
| 165 | + * @param bool $isvalid, allows for multiple colons and characters set as illegal |
165 | 166 | * @return Title the new object, or NULL on an error |
166 | 167 | * @static |
167 | 168 | * @access public |
168 | 169 | */ |
169 | | - public static function newFromURL( $url ) { |
| 170 | + public static function newFromURL( $url, $isvalid=true ) { |
170 | 171 | global $wgLegalTitleChars; |
171 | 172 | $t = new Title(); |
172 | 173 | |
— | — | @@ -177,7 +178,7 @@ |
178 | 179 | } |
179 | 180 | |
180 | 181 | $t->mDbkeyform = str_replace( ' ', '_', $url ); |
181 | | - if( $t->secureAndSplit() ) { |
| 182 | + if( $t->secureAndSplit( $isvalid ) ) { |
182 | 183 | return $t; |
183 | 184 | } else { |
184 | 185 | return NULL; |
— | — | @@ -1692,10 +1693,11 @@ |
1693 | 1694 | * removes illegal characters, splits off the interwiki and |
1694 | 1695 | * namespace prefixes, sets the other forms, and canonicalizes |
1695 | 1696 | * everything. |
| 1697 | + * @param bool $isvalid, allows for multiple colons and characters set as illegal |
1696 | 1698 | * @return bool true on success |
1697 | 1699 | * @private |
1698 | 1700 | */ |
1699 | | - /* private */ function secureAndSplit() { |
| 1701 | + /* private */ function secureAndSplit( $isvalid=true ) { |
1700 | 1702 | global $wgContLang, $wgLocalInterwiki, $wgCapitalLinks; |
1701 | 1703 | |
1702 | 1704 | # Initialisation |
— | — | @@ -1796,7 +1798,7 @@ |
1797 | 1799 | $this->mArticleID = 0; |
1798 | 1800 | } |
1799 | 1801 | $fragment = strstr( $dbkey, '#' ); |
1800 | | - if ( false !== $fragment ) { |
| 1802 | + if ( $isvalid && false !== $fragment ) { |
1801 | 1803 | $this->setFragment( $fragment ); |
1802 | 1804 | $dbkey = substr( $dbkey, 0, strlen( $dbkey ) - strlen( $fragment ) ); |
1803 | 1805 | # remove whitespace again: prevents "Foo_bar_#" |
— | — | @@ -1806,7 +1808,7 @@ |
1807 | 1809 | |
1808 | 1810 | # Reject illegal characters. |
1809 | 1811 | # |
1810 | | - if( preg_match( $rxTc, $dbkey ) ) { |
| 1812 | + if( $isvalid && preg_match( $rxTc, $dbkey ) ) { |
1811 | 1813 | return false; |
1812 | 1814 | } |
1813 | 1815 | |