- From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 29 Jun 2009 18:21:18 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv17131/httpd/cgi-bin
Modified Files:
check
Log Message:
Fix JSON output errors (missing/extra commas, incorrect escaping) (#7000). New dependency: JSON >= 2.00.
Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.663
retrieving revision 1.664
diff -u -d -r1.663 -r1.664
--- check 29 Jun 2009 14:35:22 -0000 1.663
+++ check 29 Jun 2009 18:21:16 -0000 1.664
@@ -59,6 +59,7 @@
use HTTP::Message 1.52 qw(); # Need 1.52 for decoded_content()
use HTTP::Request qw();
use HTTP::Headers::Auth qw(); # Needs to be imported after other HTTP::*.
+use JSON 2.00 qw();
use SGML::Parser::OpenSP qw();
use URI qw();
use URI::Escape qw(uri_escape);
@@ -1321,6 +1322,21 @@
# if $template->param('opt_show_raw_errors');
# $T->param(file_outline => &outline($File)) if $T->param('opt_show_outline');
+if ($File->{Opt}->{Output} eq 'json') {
+ # No JSON escaping in HTML::Template (and "JS" is not the right thing here)
+ my $json = JSON->new();
+ $json->allow_nonref(TRUE);
+ for my $msgs ($template->param("file_errors"),
+ $template->param("file_warnings")) {
+ next unless $msgs;
+ for my $msg (@$msgs) {
+ for my $key (qw(msg expl)) {
+ $msg->{$key} = $json->encode($msg->{$key}) if $msg->{$key};
+ }
+ }
+ }
+}
+
# transcode output from perl's internal to utf-8 and output
print Encode::encode('UTF-8', $template->output);
Received on Monday, 29 June 2009 18:21:27 UTC