Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1498,4 +1498,20 @@ |
1499 | 1499 | function in_string( $needle, $str ) { |
1500 | 1500 | return strpos( $str, $needle ) !== false; |
1501 | 1501 | } |
| 1502 | + |
| 1503 | +/** |
| 1504 | + * Returns a regular expression of url protocols |
| 1505 | + * |
| 1506 | + * @return string |
| 1507 | + */ |
| 1508 | +function wfUrlProtocols() { |
| 1509 | + global $wgUrlProtocols; |
| 1510 | + |
| 1511 | + $x = array(); |
| 1512 | + foreach ($wgUrlProtocols as $protocol) |
| 1513 | + $x[] = preg_quote( $protocol, '/' ); |
| 1514 | + |
| 1515 | + return implode( '|', $x ); |
| 1516 | +} |
| 1517 | + |
1502 | 1518 | ?> |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | define( 'EXT_LINK_TEXT_CLASS', '[^\]\\x00-\\x1F\\x7F]' ); |
56 | 56 | define( 'EXT_IMAGE_FNAME_CLASS', '[A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]' ); |
57 | 57 | define( 'EXT_IMAGE_EXTENSIONS', 'gif|png|jpg|jpeg' ); |
58 | | -define( 'EXT_LINK_BRACKETED', '/\[(\b('.$wgUrlProtocols.')'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' ); |
| 58 | +define( 'EXT_LINK_BRACKETED', '/\[(\b(' . wfUrlProtocols() . ')'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' ); |
59 | 59 | define( 'EXT_IMAGE_REGEX', |
60 | 60 | '/^('.HTTP_PROTOCOLS.')'. # Protocol |
61 | 61 | '('.EXT_LINK_URL_CLASS.'+)\\/'. # Hostname and path |
— | — | @@ -1121,12 +1121,11 @@ |
1122 | 1122 | * @access private |
1123 | 1123 | */ |
1124 | 1124 | function replaceFreeExternalLinks( $text ) { |
1125 | | - global $wgUrlProtocols; |
1126 | 1125 | global $wgContLang; |
1127 | 1126 | $fname = 'Parser::replaceFreeExternalLinks'; |
1128 | 1127 | wfProfileIn( $fname ); |
1129 | 1128 | |
1130 | | - $bits = preg_split( '/(\b(?:'.$wgUrlProtocols.'))/S', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
| 1129 | + $bits = preg_split( '/(\b(?:' . wfUrlProtocols() . '))/S', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
1131 | 1130 | $s = array_shift( $bits ); |
1132 | 1131 | $i = 0; |
1133 | 1132 | |
— | — | @@ -1208,7 +1207,7 @@ |
1209 | 1208 | * @access private |
1210 | 1209 | */ |
1211 | 1210 | function replaceInternalLinks( $s ) { |
1212 | | - global $wgContLang, $wgLinkCache, $wgUrlProtocols; |
| 1211 | + global $wgContLang, $wgLinkCache; |
1213 | 1212 | static $fname = 'Parser::replaceInternalLinks' ; |
1214 | 1213 | |
1215 | 1214 | wfProfileIn( $fname ); |
— | — | @@ -1310,7 +1309,7 @@ |
1311 | 1310 | # Don't allow internal links to pages containing |
1312 | 1311 | # PROTO: where PROTO is a valid URL protocol; these |
1313 | 1312 | # should be external links. |
1314 | | - if (preg_match('/^(\b(?:'.$wgUrlProtocols.'))/', $m[1])) { |
| 1313 | + if (preg_match('/^(\b(?:' . wfUrlProtocols() . '))/', $m[1])) { |
1315 | 1314 | $s .= $prefix . '[[' . $line ; |
1316 | 1315 | continue; |
1317 | 1316 | } |
— | — | @@ -1406,7 +1405,7 @@ |
1407 | 1406 | $text = $this->replaceInternalLinks($text); |
1408 | 1407 | |
1409 | 1408 | # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them |
1410 | | - $s .= $prefix . preg_replace("/\b($wgUrlProtocols)/", UNIQ_PREFIX."NOPARSE$1", $this->makeImage( $nt, $text) ) . $trail; |
| 1409 | + $s .= $prefix . preg_replace( "/\b(" . wfUrlProtocols() . ')/', UNIQ_PREFIX."NOPARSE$1", $this->makeImage( $nt, $text) ) . $trail; |
1411 | 1410 | $wgLinkCache->addImageLinkObj( $nt ); |
1412 | 1411 | |
1413 | 1412 | wfProfileOut( "$fname-image" ); |
Index: trunk/phase3/includes/Sanitizer.php |
— | — | @@ -525,7 +525,6 @@ |
526 | 526 | * @todo Check for unique id attribute :P |
527 | 527 | */ |
528 | 528 | function fixTagAttributes( $text, $element ) { |
529 | | - global $wgUrlProtocols; |
530 | 529 | if( trim( $text ) == '' ) { |
531 | 530 | return ''; |
532 | 531 | } |
— | — | @@ -585,7 +584,7 @@ |
586 | 585 | |
587 | 586 | # Stupid hack |
588 | 587 | $value = preg_replace_callback( |
589 | | - '/(' . $wgUrlProtocols . ')/', |
| 588 | + '/(' . wfUrlProtocols() . ')/', |
590 | 589 | array( 'Sanitizer', 'armorLinksCallback' ), |
591 | 590 | $value ); |
592 | 591 | |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -1272,8 +1272,7 @@ |
1273 | 1273 | # If url string starts with http, consider as external URL, else |
1274 | 1274 | # internal |
1275 | 1275 | /*static*/ function makeInternalOrExternalUrl( $name ) { |
1276 | | - global $wgUrlProtocols; |
1277 | | - if ( preg_match( '/^(?:' . $wgUrlProtocols . ')/', $name ) ) { |
| 1276 | + if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) { |
1278 | 1277 | return $name; |
1279 | 1278 | } else { |
1280 | 1279 | return $this->makeUrl( $name ); |