Index: trunk/phase3/includes/Parser.php |
— | — | @@ -47,7 +47,6 @@ |
48 | 48 | define( 'UNIQ_PREFIX', 'NaodW29'); |
49 | 49 | |
50 | 50 | # Constants needed for external link processing |
51 | | -define( 'URL_PROTOCOLS', 'http:\/\/|https:\/\/|ftp:\/\/|irc:\/\/|gopher:\/\/|news:|mailto:' ); |
52 | 51 | define( 'HTTP_PROTOCOLS', 'http:\/\/|https:\/\/' ); |
53 | 52 | # Everything except bracket, space, or control characters |
54 | 53 | define( 'EXT_LINK_URL_CLASS', '[^]<>"\\x00-\\x20\\x7F]' ); |
— | — | @@ -55,7 +54,7 @@ |
56 | 55 | define( 'EXT_LINK_TEXT_CLASS', '[^\]\\x00-\\x1F\\x7F]' ); |
57 | 56 | define( 'EXT_IMAGE_FNAME_CLASS', '[A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]' ); |
58 | 57 | define( 'EXT_IMAGE_EXTENSIONS', 'gif|png|jpg|jpeg' ); |
59 | | -define( 'EXT_LINK_BRACKETED', '/\[(\b('.URL_PROTOCOLS.')'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' ); |
| 58 | +define( 'EXT_LINK_BRACKETED', '/\[(\b('.$wgUrlProtcols.')'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' ); |
60 | 59 | define( 'EXT_IMAGE_REGEX', |
61 | 60 | '/^('.HTTP_PROTOCOLS.')'. # Protocol |
62 | 61 | '('.EXT_LINK_URL_CLASS.'+)\\/'. # Hostname and path |
— | — | @@ -1105,11 +1104,12 @@ |
1106 | 1105 | * @access private |
1107 | 1106 | */ |
1108 | 1107 | function replaceFreeExternalLinks( $text ) { |
| 1108 | + global $wgUrlProtcols; |
1109 | 1109 | global $wgContLang; |
1110 | 1110 | $fname = 'Parser::replaceFreeExternalLinks'; |
1111 | 1111 | wfProfileIn( $fname ); |
1112 | 1112 | |
1113 | | - $bits = preg_split( '/(\b(?:'.URL_PROTOCOLS.'))/S', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
| 1113 | + $bits = preg_split( '/(\b(?:'.$wgUrlProtcols.'))/S', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
1114 | 1114 | $s = array_shift( $bits ); |
1115 | 1115 | $i = 0; |
1116 | 1116 | |
— | — | @@ -1187,7 +1187,7 @@ |
1188 | 1188 | * @access private |
1189 | 1189 | */ |
1190 | 1190 | function replaceInternalLinks( $s ) { |
1191 | | - global $wgContLang, $wgLinkCache; |
| 1191 | + global $wgContLang, $wgLinkCache, $wgUrlProtcols; |
1192 | 1192 | static $fname = 'Parser::replaceInternalLinks' ; |
1193 | 1193 | |
1194 | 1194 | wfProfileIn( $fname ); |
— | — | @@ -1290,7 +1290,7 @@ |
1291 | 1291 | # Don't allow internal links to pages containing |
1292 | 1292 | # PROTO: where PROTO is a valid URL protocol; these |
1293 | 1293 | # should be external links. |
1294 | | - if (preg_match('/^(\b(?:'.URL_PROTOCOLS.'))/', $m[1])) { |
| 1294 | + if (preg_match('/^(\b(?:'.$wgUrlProtcols.'))/', $m[1])) { |
1295 | 1295 | $s .= $prefix . '[[' . $line ; |
1296 | 1296 | continue; |
1297 | 1297 | } |
Index: trunk/phase3/includes/Sanitizer.php |
— | — | @@ -525,6 +525,7 @@ |
526 | 526 | * @todo Check for unique id attribute :P |
527 | 527 | */ |
528 | 528 | function fixTagAttributes( $text, $element ) { |
| 529 | + global $wgUrlProtcols; |
529 | 530 | if( trim( $text ) == '' ) { |
530 | 531 | return ''; |
531 | 532 | } |
— | — | @@ -571,7 +572,7 @@ |
572 | 573 | 'PMID' => 'PMID', |
573 | 574 | ) ); |
574 | 575 | $value = preg_replace( |
575 | | - '/(' . URL_PROTOCOLS . '):/', |
| 576 | + '/(' . $wgUrlProtcols . '):/', |
576 | 577 | '\\1:', $value ); |
577 | 578 | |
578 | 579 | // If this attribute was previously set, override it. |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -121,6 +121,11 @@ |
122 | 122 | $wgUploadBaseUrl = ""; |
123 | 123 | /**#@-*/ |
124 | 124 | |
| 125 | +/** |
| 126 | + * The external URL protocols (regexp) |
| 127 | + */ |
| 128 | +$wgUrlProtcols = 'http:\/\/|https:\/\/|ftp:\/\/|irc:\/\/|gopher:\/\/|news:|mailto:'; |
| 129 | + |
125 | 130 | /** internal name of virus scanner. This servers as a key to the $wgAntivirusSetup array. |
126 | 131 | * Set this to NULL to disable virus scanning. If not null, every file uploaded will be scanned for viruses. |
127 | 132 | * @global string $wgAntivirus |