/[suikacvs]/test/html-webhacc/cc.cgi
Suika

Diff of /test/html-webhacc/cc.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by wakaba, Sun Nov 18 05:30:03 2007 UTC revision 1.28 by wakaba, Fri Nov 23 06:36:19 2007 UTC
# Line 52  sub htescape ($) { Line 52  sub htescape ($) {
52    
53    $| = 0;    $| = 0;
54    my $input = get_input_document ($http, $dom);    my $input = get_input_document ($http, $dom);
   my $inner_html_element = $http->get_parameter ('e');  
55    my $char_length = 0;    my $char_length = 0;
56    my %time;    my %time;
57    
# Line 253  sub print_syntax_error_html_section ($$) Line 252  sub print_syntax_error_html_section ($$)
252    
253    my $doc = $dom->create_document;    my $doc = $dom->create_document;
254    my $el;    my $el;
255      my $inner_html_element = $http->get_parameter ('e');
256    if (defined $inner_html_element and length $inner_html_element) {    if (defined $inner_html_element and length $inner_html_element) {
257      $input->{charset} ||= 'ISO-8859-1'; ## TODO: for now.      $input->{charset} ||= 'windows-1252'; ## TODO: for now.
258      my $time1 = time;      my $time1 = time;
259      my $t = Encode::decode ($input->{charset}, $input->{s});      my $t = Encode::decode ($input->{charset}, $input->{s});
260      $time{decode} = time - $time1;      $time{decode} = time - $time1;
# Line 270  sub print_syntax_error_html_section ($$) Line 270  sub print_syntax_error_html_section ($$)
270          ($input->{charset}, $input->{s} => $doc, $onerror);          ($input->{charset}, $input->{s} => $doc, $onerror);
271      $time{parse_html} = time - $time1;      $time{parse_html} = time - $time1;
272    }    }
273      $doc->manakai_charset ($input->{official_charset})
274          if defined $input->{official_charset};
275        
276    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl></div>];
277    
# Line 310  sub print_syntax_error_xml_section ($$) Line 312  sub print_syntax_error_xml_section ($$)
312    my $doc = Message::DOM::XMLParserTemp->parse_byte_stream    my $doc = Message::DOM::XMLParserTemp->parse_byte_stream
313        ($fh => $dom, $onerror, charset => $input->{charset});        ($fh => $dom, $onerror, charset => $input->{charset});
314    $time{parse_xml} = time - $time1;    $time{parse_xml} = time - $time1;
315      $doc->manakai_charset ($input->{official_charset})
316          if defined $input->{official_charset};
317    
318    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl></div>];
319    
# Line 399  sub print_document_tree ($) { Line 403  sub print_document_tree ($) {
403          $r .= '<ul class="attributes">';          $r .= '<ul class="attributes">';
404          for my $attr (sort {$a->[0] cmp $b->[0]} map { [$_->name, $_->value, $_->namespace_uri, 'node-'.refaddr $_] }          for my $attr (sort {$a->[0] cmp $b->[0]} map { [$_->name, $_->value, $_->namespace_uri, 'node-'.refaddr $_] }
405                        @{$child->attributes}) {                        @{$child->attributes}) {
406            $r .= qq[<li id="$attr->[3]" class="tree-attribute"><code title="@{[defined $_->[2] ? $_->[2] : '']}">] . htescape ($attr->[0]) . '</code> = '; ## ISSUE: case?            $r .= qq[<li id="$attr->[3]" class="tree-attribute"><code title="@{[defined $attr->[2] ? htescape ($attr->[2]) : '']}">] . htescape ($attr->[0]) . '</code> = '; ## ISSUE: case?
407            $r .= '<q>' . htescape ($attr->[1]) . '</q></li>'; ## TODO: children            $r .= '<q>' . htescape ($attr->[1]) . '</q></li>'; ## TODO: children
408          }          }
409          $r .= '</ul>';          $r .= '</ul>';
# Line 420  sub print_document_tree ($) { Line 424  sub print_document_tree ($) {
424      } elsif ($nt == $child->DOCUMENT_NODE) {      } elsif ($nt == $child->DOCUMENT_NODE) {
425        $r .= qq'<li id="$node_id" class="tree-document">Document';        $r .= qq'<li id="$node_id" class="tree-document">Document';
426        $r .= qq[<ul class="attributes">];        $r .= qq[<ul class="attributes">];
427          my $cp = $child->manakai_charset;
428          if (defined $cp) {
429            $r .= qq[<li><code>charset</code> parameter = <code>];
430            $r .= htescape ($cp) . qq[</code></li>];
431          }
432          $r .= qq[<li><code>inputEncoding</code> = ];
433          my $ie = $child->input_encoding;
434          if (defined $ie) {
435            $r .= qq[<code>@{[htescape ($ie)]}</code>];
436            if ($child->manakai_has_bom) {
437              $r .= qq[ (with <code class=charname><abbr>BOM</abbr></code>)];
438            }
439          } else {
440            $r .= qq[(<code>null</code>)];
441          }
442        $r .= qq[<li>@{[scalar get_text ('manakaiIsHTML:'.($child->manakai_is_html?1:0))]}</li>];        $r .= qq[<li>@{[scalar get_text ('manakaiIsHTML:'.($child->manakai_is_html?1:0))]}</li>];
443        $r .= qq[<li>@{[scalar get_text ('manakaiCompatMode:'.$child->manakai_compat_mode)]}</li>];        $r .= qq[<li>@{[scalar get_text ('manakaiCompatMode:'.$child->manakai_compat_mode)]}</li>];
444        unless ($child->manakai_is_html) {        unless ($child->manakai_is_html) {
# Line 895  sub get_node_link ($) { Line 914  sub get_node_link ($) {
914    
915  sub load_text_catalog ($) {  sub load_text_catalog ($) {
916    my $lang = shift; # MUST be a canonical lang name    my $lang = shift; # MUST be a canonical lang name
917    open my $file, '<', "cc-msg.$lang.txt" or die "$0: cc-msg.$lang.txt: $!";    open my $file, '<:utf8', "cc-msg.$lang.txt"
918          or die "$0: cc-msg.$lang.txt: $!";
919    while (<$file>) {    while (<$file>) {
920      if (s/^([^;]+);([^;]*);//) {      if (s/^([^;]+);([^;]*);//) {
921        my ($type, $cls, $msg) = ($1, $2, $_);        my ($type, $cls, $msg) = ($1, $2, $_);
# Line 994  EOH Line 1014  EOH
1014      $ua->protocols_allowed ([qw/http/]);      $ua->protocols_allowed ([qw/http/]);
1015      $ua->max_size (1000_000);      $ua->max_size (1000_000);
1016      my $req = HTTP::Request->new (GET => $request_uri);      my $req = HTTP::Request->new (GET => $request_uri);
1017        $req->header ('Accept-Encoding' => 'identity, *; q=0');
1018      my $res = $ua->request ($req);      my $res = $ua->request ($req);
1019      ## TODO: 401 sets |is_success| true.      ## TODO: 401 sets |is_success| true.
1020      if ($res->is_success or $http->get_parameter ('error-page')) {      if ($res->is_success or $http->get_parameter ('error-page')) {
# Line 1006  EOH Line 1027  EOH
1027        if (defined $ct and $ct =~ /;\s*charset\s*=\s*"?([^\s;"]+)"?/i) {        if (defined $ct and $ct =~ /;\s*charset\s*=\s*"?([^\s;"]+)"?/i) {
1028          $r->{charset} = lc $1;          $r->{charset} = lc $1;
1029          $r->{charset} =~ tr/\\//d;          $r->{charset} =~ tr/\\//d;
1030            $r->{official_charset} = $r->{charset};
1031        }        }
1032    
1033        my $input_charset = $http->get_parameter ('charset');        my $input_charset = $http->get_parameter ('charset');
# Line 1049  EOH Line 1071  EOH
1071      $r->{charset} = ''.$http->get_parameter ('_charset_');      $r->{charset} = ''.$http->get_parameter ('_charset_');
1072      $r->{charset} =~ s/\s+//g;      $r->{charset} =~ s/\s+//g;
1073      $r->{charset} = 'utf-8' if $r->{charset} eq '';      $r->{charset} = 'utf-8' if $r->{charset} eq '';
1074        $r->{official_charset} = $r->{charset};
1075      $r->{header_field} = [];      $r->{header_field} = [];
1076    
1077      require Whatpm::ContentType;      require Whatpm::ContentType;
# Line 1076  EOH Line 1099  EOH
1099    if ($r->{media_type} eq 'text/xml') {    if ($r->{media_type} eq 'text/xml') {
1100      unless (defined $r->{charset}) {      unless (defined $r->{charset}) {
1101        $r->{charset} = 'us-ascii';        $r->{charset} = 'us-ascii';
1102          $r->{official_charset} = $r->{charset};
1103      } elsif ($r->{charset_overridden} and $r->{charset} eq 'us-ascii') {      } elsif ($r->{charset_overridden} and $r->{charset} eq 'us-ascii') {
1104        $r->{charset_overridden} = 0;        $r->{charset_overridden} = 0;
1105      }      }

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.28

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24