Invalid (X)HTML generated by theme function

naquah - March 29, 2007 - 22:04
Project:Signwriter
Version:5.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

When using signwriter with a title with a single quote in it, like Who's online, the function theme_signwriter_text_convert generates invalid markup. I get this error from the W3 validator:

Error Line 186 column 136: an attribute value literal can occur in an attribute specification list only after a VI delimiter.
...f7601a5e55b562.gif' alt='Who's online' /<

I propose to change the single quotes for attributes in that theme function to be double quotes (they are more 'mainstream') and to replace quotes in the attribute values with entities.

#1

Agileware - May 16, 2007 - 04:10
Status:active» fixed

I've added a call to htmlspecialchars for the image alt text to fix this in cvs.

#2

naquah - May 19, 2007 - 12:28
Status:fixed» active

Please also change the single quotes to double quotes for consistency with the rest of Drupal (and the rest of the world for that matter).

Thanks!

#3

wrunt - May 20, 2007 - 23:15
Status:active» fixed

I don't really think that's necessary. Both types of quotes are allowed by the XML spec.

#4

bobwaycott - May 31, 2007 - 22:45

I am attaching a patched signwriter.module file that fixes this issue for XHTML Strict validation. I have added in escaped quotes at the necessary line, which causes the XHTML validation to pass completely. No rendering issues occur.

If both types of quotes were allowed, this would pass XHTML Strict validation. I only work in XHTML Strict, so it is necessary to have the double quotes.

Thanks for a great module.

AttachmentSize
signwriter.module.patch 26.68 KB

#5

bobwaycott - May 31, 2007 - 22:56

Sorry, after viewing the generated source, the alt text shows up as

alt=" ' ' "

I have removed the single quote in favor of the standards-compliant double in this updated patch.

Generated source now shows:

alt=" "

Passes XHTML 1.0 Strict validation.

AttachmentSize
signwriter.module_0.patch 26.68 KB

#6

bobwaycott - June 1, 2007 - 00:01

The only issue I have is this module isn't generating the contents of $text in the <img alt=" " /> source either way. Having proper alt text is necessary for accessibility.

Any thoughts?

#7

naquah - June 9, 2007 - 13:38
Status:fixed» active

@bobwaycott: If you want the module maintainer to look at this issue, you should change this issue's status back to active (I now did). Also try to provide patches instead of complete files, as described at Patches. If you post a patch, set the issue status to patch (code needs review).

I'm all in for changing all the single quotes in the generated (x)html to double quotes. Why be different?

#8

Agileware - September 4, 2008 - 06:32
Status:active» fixed

This has been fixed in the development version of the module and will be available in the next release.

#9

Agileware - September 4, 2008 - 06:57
Status:fixed» won't fix

I've changed it back out of principle.

Here is the XML specification for XHTML Strict.
[10]   AttValue   ::=   '"' ([^<&"] | Reference)* '"' |  "'" ([^<&'] | Reference)* "'"

If you can read regular expressions, the specification clearly caters for both.

 
 

Drupal is a registered trademark of Dries Buytaert.