diff options
author | Ville Skytt? <ville.skytta@iki.fi> | 2011-03-17 23:38:37 +0200 |
---|---|---|
committer | Ville Skytt? <ville.skytta@iki.fi> | 2011-03-17 23:38:37 +0200 |
commit | 128fe61c5633de526d1959e553b8d52ae417f443 (patch) | |
tree | 1678100491a72d37fee59e4eb4efd5864da047ae | |
parent | e96c37e5adc4b25442e8c98e170dd08074edd50d (diff) | |
download | markup-validator-128fe61c5633de526d1959e553b8d52ae417f443.zip markup-validator-128fe61c5633de526d1959e553b8d52ae417f443.tar.gz markup-validator-128fe61c5633de526d1959e553b8d52ae417f443.tar.bz2 |
Work around XML::LibXML "max column = 80" issue.
http://rt.cpan.org/Public/Bug/Display.html?id=66642
-rwxr-xr-x | httpd/cgi-bin/check | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check index 5e8a4bb..89d2b66 100755 --- a/httpd/cgi-bin/check +++ b/httpd/cgi-bin/check @@ -1331,6 +1331,25 @@ sub xmlwf (\$) $err->{type} = "E"; $err->{msg} = $err_obj->message(); + # Ugly workaround for XML::LibXML reporting column 80 when the + # error occurs beyond that: + # http://rt.cpan.org/Public/Bug/Display.html?id=66642 + if ($err->{char} && $err->{char} == 80 && + # This workaround does not apply to non-document errors, i.e. + # ones that have $err->{uri}. + !$err->{uri} && $err->{line}) + { + # Get context reported by XML::LibXML, ... + my $ctx = $err_obj->context(); + if ($ctx && length($ctx) == $err->{char}) { + # ... try to locate it in our original source line, ... + my $line = $File->{Content}->[$err->{line}-1] || ''; + my $ix = index($line, $ctx); + # ... and adjust column offset accordingly. + $err->{char} += $ix if $ix > 0; + } + } + $err_obj = $err_obj->_prev(); unshift(@{$File->{WF_Errors}}, $err); |