[PATCH] Entity encoding in URI output

Right, csmith kindly pointed out what the problem was with the
validation results for debian.org (the results themselves didn't
validate. duh!). I checked out a clean tree (my development branch is
off in the twilight zone at the moment[0]) and made a quick fix. The
patch is untested[1], but shouldn't have far-reaching consequences so
I'll chance it (sorry Chris ;D).



[0] - I have a few more features to play with before I try to stabilize
it.
      "Just /one/ more feature..." :-)

[1] - The Red Hat 7.0 upgrade kindly reorganized my whole Apache setup
     (thanks a lot Red Hat!) so I'm in the process of getting a
functioning
     web server to develop on. I'll check for any major snafus when I
get
     it back up and running; maybe add this as a test case.
Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.67
diff -u -r1.67 check
--- check	2000/09/29 09:19:07	1.67
+++ check	2000/10/03 01:03:33
@@ -313,7 +313,7 @@
 # Print different things if we got redirected or had a file upload.
 if ($File->{URI} eq $q->param('uri')) {
   print ' ' x 4, qq(<li><a href="$uri_def_uri">URI</a>: );
-  print '<a href="', $File->{URI}, '">', $File->{URI}, qq(</a>\n);
+  print '<a href="', ent($File->{URI}), '">', ent($File->{URI}), qq(</a>\n);
 } elsif ($q->param('uploaded_file')) {
   print ' ' x 4, '<li>File: ', $File->{URI}, "</li>\n";
 } else {
@@ -1377,4 +1377,12 @@
   $file =~ s(\015)    {\n}g; # Turn ASCII CR   into native newline.
 
   return [split /\n/, $file];
+}
+
+#
+# Return $_[0] encoded for HTML entities (cribbed from merlyn).
+sub ent {
+  local $_ = shift;
+  s(["<&>"]){'&#' . ord($&) . ';'}ge;
+  return $_;
 }

Received on Monday, 2 October 2000 21:14:30 UTC