From baa477ac08808e2313bfb84993b7f212294ac25a Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 8 Mar 2010 01:22:21 -0500 Subject: [PATCH] Truncate alt text from src if it's too long. Signed-off-by: Edward Z. Yang --- TODO | 7 ------- library/HTMLPurifier/AttrTransform/ImgRequired.php | 3 ++- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index f09261c3..2a282f55 100644 --- a/TODO +++ b/TODO @@ -11,18 +11,11 @@ If no interest is expressed for a feature that may require a considerable amount of effort to implement, it may get endlessly delayed. Do not be afraid to cast your vote for the next feature to be implemented! -Standing patches: - - - Incorporate download and resize support as implemented here: - http://htmlpurifier.org/phorum/read.php?3,2795,3628 - Things to do as soon as possible: - - Fix ImgRequired to handle data correctly - Think about allowing explicit order of operations hooks for transforms - Inputs don't do the right thing with submit - Fix "<.<" bug (trailing < is removed if not EOD) - - http://htmlpurifier.org/phorum/read.php?5,2267,4308#msg-4308 - Build in better internal state dumps and debugging tools for remote debugging diff --git a/library/HTMLPurifier/AttrTransform/ImgRequired.php b/library/HTMLPurifier/AttrTransform/ImgRequired.php index a219479a..7f0e4b7a 100644 --- a/library/HTMLPurifier/AttrTransform/ImgRequired.php +++ b/library/HTMLPurifier/AttrTransform/ImgRequired.php @@ -24,7 +24,8 @@ class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform if ($src) { $alt = $config->get('Attr.DefaultImageAlt'); if ($alt === null) { - $attr['alt'] = basename($attr['src']); + // truncate if the alt is too long + $attr['alt'] = substr(basename($attr['src']),0,40); } else { $attr['alt'] = $alt; }