So, I felt like rewriting the WebUI to be valid XHTML valid today, and came across a problem with which I need some CGI help:

dspam.cgi takes and replaces > characters with &gt; (as well as < with &lt;, though this doesn't matter.):

  1. $from =~ s/</&lt;/g;
  2. $from =~ s/>/&gt;/g;
  3. $subject =~ s/</&lt;/g;
  4. $subject =~ s/>/&gt;/g;

dspam.cgi then takes and truncates the from and subject lines if they are longer than MAX_COL_LEN, which is set in configure.pl, and adds ... to the end:

  1. $from = substr($from, 0, ($CONFIG{'MAX_COL_LEN'} + 3)) . "..." if
     (length($from)>$CONFIG{'MAX_COL_LEN'});
  2. $subject = substr($subject, 0, ($CONFIG{'MAX_COL_LEN'} + 3)) .
     "..." if (length($subject)>$CONFIG{'MAX_COL_LEN'});

The problem with this is that &gt; is 3 characters longer than >, which ends up truncating the wrong part of the lines, resulting in invalid code:

  1. <td class="rowEven" nowrap="nowrap"><small>"Dolores"
     &lt;[EMAIL PROTECTED]&gt...</small></td> or
     "Dolores" <[EMAIL PROTECTED]&gt...
     instead of
  2. <td class="rowEven" nowrap="nowrap"><small>"Dolores"
     &lt;[EMAIL PROTECTED]&gt;...</small></td> or
     "Dolores" <[EMAIL PROTECTED]>

See what I mean? I might be way off on the cause as to why this happens, but regardless, it does.

Anyone mind telling me how to fix this? I'll include it in the valid-xhtml patch that I am trying to put together.

Thanks,
Kyle

Reply via email to