diff options
author | rxu <rxu@mail.ru> | 2015-01-10 02:25:49 +0700 |
---|---|---|
committer | rxu <rxu@mail.ru> | 2015-01-10 03:21:36 +0700 |
commit | d86bdcb2a75a000dd30478216644e8f1d3dae9dd (patch) | |
tree | 3a957815c27468976522b0bf5dfbcec4bba122b3 /phpBB/develop | |
parent | a8c62e707af0971a62b7601f4ac6ea46f57b16c2 (diff) | |
download | forums-d86bdcb2a75a000dd30478216644e8f1d3dae9dd.tar forums-d86bdcb2a75a000dd30478216644e8f1d3dae9dd.tar.gz forums-d86bdcb2a75a000dd30478216644e8f1d3dae9dd.tar.bz2 forums-d86bdcb2a75a000dd30478216644e8f1d3dae9dd.tar.xz forums-d86bdcb2a75a000dd30478216644e8f1d3dae9dd.zip |
[ticket/12926] Get rid of the $scheme and $inline vars, fix regex_idn.php
Get rid of the $scheme and $inline vars, fix regex_idn.php to generate
both common and inline mode regexes all at once.
PHPBB3-12926
Diffstat (limited to 'phpBB/develop')
-rw-r--r-- | phpBB/develop/regex_idn.php | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/phpBB/develop/regex_idn.php b/phpBB/develop/regex_idn.php index 4124829a11..d871695c50 100644 --- a/phpBB/develop/regex_idn.php +++ b/phpBB/develop/regex_idn.php @@ -8,7 +8,6 @@ // die("Please read the first lines of this script for instructions on how to enable it"); - // IP regular expressions $dec_octet = '(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])'; @@ -111,33 +110,42 @@ $add_deviations = '\x{00DF}\x{03C2}\x{200C}\x{200D}'; $remove_chars = "$no_cc$no_symbol$no_hangul$no_cdm$no_musical$no_ancient_greek_musical$no_certain_exceptions"; $add_chars = "$add_certain_exceptions$add_deviations"; -$pct_encoded = "%[\dA-F]{2}"; -$unreserved = "$add_chars\pL0-9\-._~"; -$sub_delims = '!$&\'()*+,;='; -$pchar = "(?:[^$remove_chars]*[$unreserved$sub_delims:@|]+|$pct_encoded)"; // rfc: no "|" +// Initialize inline mode +$inline = false; + +do +{ + $inline = !$inline; -$scheme = '[a-z][a-z\d+\-.]*'; -$reg_name = "(?:[^$remove_chars]*[$unreserved$sub_delims:@|]+|$pct_encoded)+"; // rfc: * instead of + and no "|" and no "@" and no ":" (included instead of userinfo) -//$userinfo = "(?:(?:[$unreserved$sub_delims:]+|$pct_encoded))*"; -$ipv4_simple = '[0-9.]+'; -$ipv6_simple = '\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\]'; -$host = "(?:$reg_name|$ipv4_simple|$ipv6_simple)"; -$port = '\d*'; -//$authority = "(?:$userinfo@)?$host(?::$port)?"; -$authority = "$host(?::$port)?"; -$segment = "$pchar*"; -$path_abempty = "(?:/$segment)*"; -$hier_part = "/{2}$authority$path_abempty"; -$query = "(?:[^$remove_chars]*[$unreserved$sub_delims:@/?|]+|$pct_encoded)*"; // pchar | "/" | "?", rfc: no "|" -$fragment = $query; + $pct_encoded = "%[\dA-F]{2}"; + $unreserved = "$add_chars\pL0-9\-._~"; + $sub_delims = ($inline) ? '!$&\'(*+,;=' : '!$&\'()*+,;='; + $scheme = ($inline) ? '[a-z][a-z\d+]*': '[a-z][a-z\d+\-.]*' ; // avoid automatic parsing of "word" in "last word.http://..." + $pchar = "(?:[^$remove_chars]*[$unreserved$sub_delims:@|]+|$pct_encoded)"; // rfc: no "|" -$url = "$scheme:$hier_part(?:\?$query)?(?:\#$fragment)?"; -echo 'URL: ' . $url . "<br /><br />\n\n"; + $reg_name = "(?:[^$remove_chars]*[$unreserved$sub_delims:@|]+|$pct_encoded)+"; // rfc: * instead of + and no "|" and no "@" and no ":" (included instead of userinfo) + //$userinfo = "(?:(?:[$unreserved$sub_delims:]+|$pct_encoded))*"; + $ipv4_simple = '[0-9.]+'; + $ipv6_simple = '\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\]'; + $host = "(?:$reg_name|$ipv4_simple|$ipv6_simple)"; + $port = '\d*'; + //$authority = "(?:$userinfo@)?$host(?::$port)?"; + $authority = "$host(?::$port)?"; + $segment = "$pchar*"; + $path_abempty = "(?:/$segment)*"; + $hier_part = "/{2}$authority$path_abempty"; + $query = "(?:[^$remove_chars]*[$unreserved$sub_delims:@/?|]+|$pct_encoded)*"; // pchar | "/" | "?", rfc: no "|" + $fragment = $query; -// no scheme, shortened authority, but host has to start with www. -$www_url = "www\.$reg_name(?::$port)?$path_abempty(?:\?$query)?(?:\#$fragment)?"; -echo 'www.URL: ' . $www_url . "<br /><br />\n\n"; + $url = "$scheme:$hier_part(?:\?$query)?(?:\#$fragment)?"; + echo (($inline) ? 'URL inline: ' : 'URL: ') . $url . "<br /><br />\n\n"; -// no schema and no authority -$relative_url = "$segment$path_abempty(?:\?$query)?(?:\#$fragment)?"; -echo 'relative URL: ' . $relative_url . "<br /><br />\n\n"; + // no scheme, shortened authority, but host has to start with www. + $www_url = "www\.$reg_name(?::$port)?$path_abempty(?:\?$query)?(?:\#$fragment)?"; + echo (($inline) ? 'www.URL_inline: ' : 'www.URL: ') . $www_url . "<br /><br />\n\n"; + + // no schema and no authority + $relative_url = "$segment$path_abempty(?:\?$query)?(?:\#$fragment)?"; + echo (($inline) ? 'relative URL inline: ' : 'relative URL: ') . $relative_url . "<br /><br />\n\n"; +} +while ($inline); |