[Rt-devel] [PATCH 3.7-RTIR-RELENG] XHTML nitpicks - Widgets/TitleBoxStart

Jason Long jlong at messiah.edu
Tue Oct 30 12:23:48 EDT 2007


Widgets/TitleBoxStart generates code like this:

  <div class="titlebox " id="">
  ...
  <div class="titlebox-content "
    id="TitleBox--_Prefs_Other.html------Date and time---0">

For the first div, XHTML validator complains:

  syntax of attribute value does not conform to declared value .

For the second quoted div, XHTML validator complains:

  value of attribute "id" must be a single token .

In other words, better to not even put an id attribute if you don't
have a value, and id values should be sanitized. See patch below.
---

 html/Widgets/TitleBoxStart |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/html/Widgets/TitleBoxStart b/html/Widgets/TitleBoxStart
index 704caa7..9d954c8 100755
--- a/html/Widgets/TitleBoxStart
+++ b/html/Widgets/TitleBoxStart
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-<div class="titlebox <% $class %>" id="<% $id %>">
+<div class="titlebox <% $class %>"<% $id ? qq[ id="$id"] : ''|n %>>
   <div class="titlebox-title<% $title_class && " $title_class" %>">
 % if ($hideable) {
     <span class="widget"><a href="#" onclick="return rollup('<%$tid%>');" onfocus="this.blur(); return false;" title="Toggle visibility">X</a></span>
@@ -78,7 +78,7 @@ my $page = $m->request_comp->path;
 my $tid  = "TitleBox--$page--" .
             join '--', ($class, $bodyclass, $title, $id);
 
-$tid =~ s{/}{_}g;
+$tid =~ s{[/\s]+}{_}g;
 
 my $i = 0;
 $i++ while $m->notes("$tid-$i");



More information about the Rt-devel mailing list