W3C home > Mailing lists > Public > www-validator-cvs@w3.org > January 2008

validator/httpd/cgi-bin check,1.578,1.579

From: Olivier Thereaux via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 17 Jan 2008 08:09:26 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1JFPoU-0004gL-2B@lionel-hutz.w3.org>

Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv17922/httpd/cgi-bin

Modified Files:
	check 
Log Message:
check that in a DOCTYPE declaration for a known document type, FPI and SI match

Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.578
retrieving revision 1.579
diff -u -d -r1.578 -r1.579
--- check	21 Nov 2007 06:55:48 -0000	1.578
+++ check	17 Jan 2008 08:09:23 -0000	1.579
@@ -1879,6 +1879,17 @@
   return \@source;
 }
 
+
+sub match_DTD_FPI_SI {
+    my ($File, $FPI, $SI) = @_;
+    if ($CFG->{Types}->{$FPI}) {
+        if ($CFG->{Types}->{$FPI}->{SysID}){
+            if ($SI ne $CFG->{Types}->{$FPI}->{SysID}) {
+                &add_warning('W26', {W26_dtd_pub => $CFG->{Types}->{$FPI}->{Display}, W26_dtd_sys=> $SI, W26_dtd_sys_recommend=> $CFG->{Types}->{$FPI}->{SysID}});
+            }
+        }
+    }
+}
 #
 # Do an initial parse of the Document Entity to extract FPI.
 sub preparse_doctype {
@@ -1892,7 +1903,13 @@
   my $dtd = sub {
     return if $File->{Root};
     # TODO: The \s and \w are probably wrong now that the strings are utf8_on
-    ($File->{Root}, $File->{DOCTYPE}) = shift =~ m(<!DOCTYPE\s+(\w[\w\.-]+)\s+(?:PUBLIC|SYSTEM)\s+(?:[\'\"])([^\"\']+)(?:[\"\']).*>)si;
+    my $declaration = shift;
+    my $doctype_type;
+    my $doctype_secondpart;
+    ($File->{Root}, $doctype_type, $File->{DOCTYPE}, $doctype_secondpart) = $declaration =~ m(<!DOCTYPE\s+(\w[\w\.-]+)\s+(PUBLIC|SYSTEM)\s+(?:[\'\"])([^\"\']+)(?:[\"\'])(.*)>)si;
+    if (($doctype_type eq "PUBLIC") and (($doctype_secondpart) = $doctype_secondpart =~ m(\s+(?:[\'\"])([^\"\']+)(?:[\"\']).*)si)){
+        &match_DTD_FPI_SI($File, $File->{DOCTYPE}, $doctype_secondpart);
+    }
   };
 
   my $start = sub {
@@ -2519,7 +2536,6 @@
   }
 }
 
-
 sub W3C::Validator::SAXHandler::start_element
 {
   my ($self, $element) = @_;
Received on Thursday, 17 January 2008 08:09:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:00 GMT