# Copyright (c) 2005-2007 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: HTML.bunit,v 1.11 2011/08/10 17:12:41 moeller Exp $ Type(); use Encode (); my($value) = '< original/value%20 >'; my($copy) = $value; [ # $] > 5.008005 ? () : ( # escape => [ # "'" => ''', # '"' => '"', # #http://www.dwheeler.com/essays/quotes-in-html.html # #http://www.alistapart.com/articles/emen/ # '“' => '“', # '”' => '”', # '‘' => '‘', # '’' => '’', # '—' => '—', #em dash # '–' => '–', #en dash # '™' => '™', # '®' => '®', # '©' => '©', # '§' => '§', # 'ö' => 'ö', # "\x{201C}" => '“', # ], # ), escape_query => [ hello => 'hello', 'hello+bye' => 'hello%2Bbye', 'hello bye' => 'hello%20bye', 'hello&bye' => 'hello%26bye', 'hello?bye' => 'hello%3Fbye', ], unescape_query => [ hello => 'hello', 'hello%2Bbye' => 'hello+bye', 'hello%20bye' => 'hello bye', 'hello%26bye' => 'hello&bye', 'hello%3Fbye' => 'hello?bye', ], unescape => [ [undef] => '', hello => 'hello', ''' => q{'}, '&><"' => q{&><"}, '©' => "\x{00A9}", '™' => "\x{2122}", '“' => "\x{201C}", map(($_->[0], Encode::decode_utf8($_->[1])), ['“' => '“'], ['”' => '”'], ['‘' => '‘'], ['’' => '’'], ['—' => '—'], #em dash ['–' => '–'], #en dash ['™' => '™'], ['®' => '®'], ['©' => '©'], ['§' => '§'], ), ], parse_www_form_urlencoded => [ [undef] => [{}], '' => [{}], 'a=1' => [{a => 1}], 'a&b' => [{a => undef, b => undef}], 'a;b' => [{a => undef, b => undef}], 'a&b=1' => [{a => undef, b => 1}], 'a;b=1&c=2' => [{a => undef, b => 1, c => 2}], 'a=1;' => [{a => 1}], 'a=1&' => [{a => 1}], '&' => [{}], ';' => [{}], ';a=1' => [{a => 1}], 'a&=1' => CORRUPT_FORM(), '=' => CORRUPT_FORM(), ], sub { class()->escape($value); class()->unescape($value); class()->escape_uri($value); class()->unescape_uri($value); return $value eq $copy ? 1 : 0; } => 1, ];