Changeset 1931

Show
Ignore:
Timestamp:
08/29/06 23:16:28
Author:
miyagawa
Message:

0.15, fix low ascii handling code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • XML-Liberal/trunk/Changes

    r1930 r1931  
    11Revision history for Perl extension XML::Liberal 
     2 
     30.15  Mon Aug 28 18:04:52 JST 2006 
     4        - Save newline, carrige return and tab in CntrolChars and LowAsciiBytes 
     5        - Handle � as well, rather than only 4 digit hex 
    26 
    370.14  Sun Aug 27 15:38:02 JST 2006 
  • XML-Liberal/trunk/lib/XML/Liberal.pm

    r1930 r1931  
    22 
    33use strict; 
    4 our $VERSION = '0.14'; 
     4our $VERSION = '0.15'; 
    55 
    66use base qw( Class::Accessor ); 
  • XML-Liberal/trunk/lib/XML/Liberal/Remedy/ControlCode.pm

    r1927 r1931  
    1111 
    1212    my $string = decode_utf8($$xml_ref); 
    13     my $match  = $string =~ s/[\x00-\x1f\x7f]//g; 
     13    my $match  = $string =~ s/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]//g; 
    1414    if ($match) { 
    1515        $$xml_ref = encode_utf8($string); 
  • XML-Liberal/trunk/lib/XML/Liberal/Remedy/LowAsciiChars.pm

    r1927 r1931  
    77    my $self = shift; 
    88    my($xml_ref) = @_; 
    9     my $match = $$xml_ref =~ s{(&#(?:(\d+)|x([0-9a-f]{4}));)}{ 
     9    my $match = $$xml_ref =~ s{(&#(?:(\d+)|x([0-9a-f]{2,4}));)}{ 
    1010        ($2 && is_low_ascii($2)) || ($3 && is_low_ascii(hex($3))) 
    1111            ? '' : $1; 
     
    1717} 
    1818 
     19my %is_low_ascii = map { $_ => 1 } (0..8, 11..12, 14..31, 127); 
     20 
    1921sub is_low_ascii { 
    2022    my $num = shift; 
    21     $num <= 31 || $num == 127
     23    $is_low_ascii{$num}
    2224} 
    2325 
  • XML-Liberal/trunk/t/04_sanity.t

    r1929 r1931  
    140140<foo>&#x3042;&#x3044;&#x3046;&#x3048;&#x304A;</foo> 
    141141 
     142=== Newline 
     143--- input 
     144<?xml version="1.0"?> 
     145<foo>foo 
     146bar</foo> 
     147--- expected 
     148<?xml version="1.0"?> 
     149<foo>foo 
     150bar</foo> 
     151 
     152=== Newline 
     153--- ONLY 
     154--- input 
     155<?xml version="1.0"?> 
     156<foo>foo&#x00;&#x0a;bar</foo> 
     157--- expected 
     158<?xml version="1.0"?> 
     159<foo>foo 
     160bar</foo>