WAI AA fix Read More title to be unique

peterx - September 12, 2007 - 11:36
Project:Drupal
Version:6.x-dev
Component:node system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

The Read More link for a teaser has the same text for every teaser. WAI AA requires a unique title if the text is not unique but the title just repeats Read More as the verbose "Read the rest of this posting.". Make the title unique by appending the title.

In node.module, change node_link from:

<?php
'attributes' => array('title' => t('Read the rest of this posting.'))
?>

to:
<?php
'attributes' => array('title' => t('Read the rest of ' . $node->title))
?>

petermoulding.com/web_architect

#1

spatz4000 - September 12, 2007 - 12:26
Version:5.x-dev» 7.x-dev

#2

webchick - September 12, 2007 - 12:39
Version:7.x-dev» 6.x-dev
Category:feature request» bug report
Status:active» needs review

This sounds more like a bug than a feature request, and therefore can be fixed in 6.x (and possibly back-ported to 5.x).

The suggested fix is a bit dangerous though; node title could contain anything, so it needs to be check_plain()ed.

So this one adds the node title as placeholder in the string.

AttachmentSize
drupal-read-more-description-174933-2.patch 716 bytes

#3

Freso - September 12, 2007 - 22:53
Status:needs review» needs work

Using my fresh D6 CVS install, I generated a bunch of (= 100) nodes with Devel Generate and went and checked the text, which said Read this posting.
I then tried to apply the patch, which went cleanly, refreshed the page and now properly got Read this [...].. However, trying with the title !"#€%&/()=?`><, I get this: title="Read the rest of !&amp;quot;#€%&amp;amp;/()=?`&amp;gt;&amp;lt;." - notice the doubly escaped ampersands! (The code for the <h2> title itself is title="!&quot;#€%&amp;/()=?`&gt;&lt;" - no doubly escaped ampersands.)

#4

Freso - September 13, 2007 - 18:39
Status:needs work» needs review

I've tried digging into the API and the code, and for all I can tell, node_link() inherits a call to l() from hook_link(), which runs the text (including attributes) through check_plain(). Which means that using @ is superfluous, and using ! should do fine. But I am must admit that I haven't been able to locate any actual references in any functions or anything, but, well, yes.

I've attached a patch with ! instead of @, please review and see if there's anywhere this isn't escaped.

AttachmentSize
drupal-read-more-description-174933.patch 726 bytes

#5

webchick - September 13, 2007 - 19:22
Status:needs review» reviewed & tested by the community

Ah-ha, I had forgotten about the check_plain() in l(). Thanks, Freso!

Looks like this is good to go.

#6

Gábor Hojtsy - September 14, 2007 - 09:38
Status:reviewed & tested by the community» fixed

Thanks. I also added a comment that the title gets escaped later, so people will not fix this "bug".

#7

peterx - September 27, 2007 - 12:17

The line
'attributes' => array('title' => t('Read the rest of !title.', array('!title' => $node->title)))
works in Drupal 5.2 and is in use on http://petermoulding.com.

Thank you for fixing the last WAI issue for Drupal and the modules in use on my site.

#8

Anonymous - October 11, 2007 - 12:31
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.