Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -20,6 +20,8 @@ |
21 | 21 | elements to work with DNSBLs that require keys, such as |
22 | 22 | Project Honeypot. |
23 | 23 | * (bug 30022) Add support for custom loadScript sources to ResourceLoader. |
| 24 | +* (bug 19052) Unicode space separator characters (Zs) now terminates external |
| 25 | + links and images links. |
24 | 26 | |
25 | 27 | === Bug fixes in 1.19 === |
26 | 28 | * $wgUploadNavigationUrl should be used for file redlinks if |
Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -9248,7 +9248,33 @@ |
9249 | 9249 | </p> |
9250 | 9250 | !! end |
9251 | 9251 | |
| 9252 | +!! test |
| 9253 | +Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate free external links |
| 9254 | +!! input |
| 9255 | +http://www.example.org/ <-- U+3000 (vim: ^Vu3000) |
| 9256 | +!! result |
| 9257 | +<p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> <-- U+3000 (vim: ^Vu3000) |
| 9258 | +</p> |
| 9259 | +!! end |
9252 | 9260 | |
| 9261 | +!! test |
| 9262 | +Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links |
| 9263 | +!! input |
| 9264 | +[http://www.example.org/ ideograms] |
| 9265 | +!! result |
| 9266 | +<p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a> |
| 9267 | +</p> |
| 9268 | +!! end |
| 9269 | + |
| 9270 | +!! test |
| 9271 | +Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate external images links |
| 9272 | +!! input |
| 9273 | +http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000) |
| 9274 | +!! result |
| 9275 | +<p><img src="http://www.example.org/pic.png" alt="pic.png" /> <-- U+3000 (vim: ^Vu3000) |
| 9276 | +</p> |
| 9277 | +!! end |
| 9278 | + |
9253 | 9279 | TODO: |
9254 | 9280 | more images |
9255 | 9281 | more tables |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -68,9 +68,11 @@ |
69 | 69 | |
70 | 70 | # Constants needed for external link processing |
71 | 71 | # Everything except bracket, space, or control characters |
72 | | - const EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F]'; |
73 | | - const EXT_IMAGE_REGEX = '/^(http:\/\/|https:\/\/)([^][<>"\\x00-\\x20\\x7F]+) |
74 | | - \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sx'; |
| 72 | + # \p{Zs} is unicode 'separator, space' category. It covers the space 0x20 |
| 73 | + # as well as U+3000 is IDEOGRAPHIC SPACE for bug 19052 |
| 74 | + const EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F\p{Zs}]'; |
| 75 | + const EXT_IMAGE_REGEX = '/^(http:\/\/|https:\/\/)([^][<>"\\x00-\\x20\\x7F\p{Zs}]+) |
| 76 | + \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sxu'; |
75 | 77 | |
76 | 78 | # State constants for the definition list colon extraction |
77 | 79 | const COLON_STATE_TEXT = 0; |
— | — | @@ -184,7 +186,7 @@ |
185 | 187 | $this->mConf = $conf; |
186 | 188 | $this->mUrlProtocols = wfUrlProtocols(); |
187 | 189 | $this->mExtLinkBracketedRegex = '/\[((' . wfUrlProtocols() . ')'. |
188 | | - '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/S'; |
| 190 | + self::EXT_LINK_URL_CLASS.'+)\p{Zs}*([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/Su'; |
189 | 191 | if ( isset( $conf['preprocessorClass'] ) ) { |
190 | 192 | $this->mPreprocessorClass = $conf['preprocessorClass']; |
191 | 193 | } elseif ( defined( 'MW_COMPILED' ) ) { |
— | — | @@ -1197,7 +1199,7 @@ |
1198 | 1200 | (?: [0-9] [\ \-]? ){9} # 9 digits with opt. delimiters |
1199 | 1201 | [0-9Xx] # check digit |
1200 | 1202 | \b) |
1201 | | - )!x', array( &$this, 'magicLinkCallback' ), $text ); |
| 1203 | + )!xu', array( &$this, 'magicLinkCallback' ), $text ); |
1202 | 1204 | wfProfileOut( __METHOD__ ); |
1203 | 1205 | return $text; |
1204 | 1206 | } |
— | — | @@ -4963,7 +4965,7 @@ |
4964 | 4966 | $value = true; |
4965 | 4967 | $validated = true; |
4966 | 4968 | } elseif ( preg_match( "/^$prots/", $value ) ) { |
4967 | | - if ( preg_match( "/^($prots)$chars+$/", $value, $m ) ) { |
| 4969 | + if ( preg_match( "/^($prots)$chars+$/u", $value, $m ) ) { |
4968 | 4970 | $paramName = 'link-url'; |
4969 | 4971 | $this->mOutput->addExternalLink( $value ); |
4970 | 4972 | if ( $this->mOptions->getExternalLinkTarget() ) { |