diff options
author | lexborisov <lex.borisov@gmail.com> | 2017-02-21 22:15:47 +0300 |
---|---|---|
committer | lexborisov <lex.borisov@gmail.com> | 2017-02-21 22:15:47 +0300 |
commit | c0877a7b5a5f98e842b865f5e0f009decaf62734 (patch) | |
tree | f113f17eec24e9edaf35d951bafbabfaa895ecac /utils | |
parent | 558280102442c7b154935bb8b5c579dae7671580 (diff) |
Sync with myhtml
Diffstat (limited to 'utils')
-rw-r--r-- | utils/MyHTML/url_resources.pl | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/utils/MyHTML/url_resources.pl b/utils/MyHTML/url_resources.pl index a52cdf0..6998c43 100644 --- a/utils/MyHTML/url_resources.pl +++ b/utils/MyHTML/url_resources.pl @@ -39,18 +39,57 @@ my $userinfo_encode = { "|" => '' }; -my $utils = MyHTML::Base->new(dirs => {source => "../../Modest/source/myhtml/url", template => "tmpl"}); +my $forbidden_host_code_point = { + "\x00" => '', + "\x09" => '', + "\x0A" => '', + "\x0D" => '', + "\x20" => '', + "#" => '', + "\%" => '', + "/" => '', + ":" => '', + "?" => '', + "\@" => '', + "[" => '', + "\\" => '', + "]" => '' +}; + +my $utils = MyHTML::Base->new(dirs => {source => "../../source/myhtml/url", template => "tmpl"}); my $utils_data = $utils->read_tmpl("url_resources.h"); $utils->save_src("resources.h", $utils_data, { BODY => - get_text_data(creare_for_default(), "myhtml_url_resources_static_map_default") . - get_text_data(creare_for_simple(), "myhtml_url_resources_static_map_simple") . + get_text_data(creare_for_forbidden_host_code_point(), "myhtml_url_resources_static_map_forbidden_host_code_point") . + "/* A C0 control is a code point in the range U+0000 to U+001F, inclusive. The C0 control percent-encode set are C0 controls and all code points greater than U+007E. */\n". + get_text_data(creare_for_simple(), "myhtml_url_resources_static_map_C0") . + '/* The path percent-encode set is the myhtml_url_resources_static_map_path and code points U+0020, \'"\', "#", "<", ">", "?", "`", "{", and "}". */'."\n". + get_text_data(creare_for_default(), "myhtml_url_resources_static_map_path") . + '/* The userinfo percent-encode set is the myhtml_url_resources_static_map_path and code points "/", ":", ";", "=", "@", "[", "\", "]", "^", and "|". */'."\n". get_text_data(creare_for_userinfo(), "myhtml_url_resources_static_map_userinfo") } ); +sub creare_for_forbidden_host_code_point { + my @data; + + for my $codepoint (0..255) { + my $char = chr($codepoint); + + if (exists $default_encode->{$char} || $char eq chr(0)) + { + push @data, sprintf("0x%02x", $codepoint); + } + else { + push @data, "0xff"; + } + } + + return \@data; +} + sub creare_for_default { my @data; |