[ic] Filter tag and html - Patch for Interpolate.pm

Daniel Davenport ddavenport at newagedigital.com
Thu Mar 24 15:12:50 EST 2005

>>> sandy at scotwebshops.com 03/24/05 10:38AM >>>
> Hi,
> We were using the character limit thing on the filter tag, and were 
> getting frustrated that it treated html entites as > 1 characters,
> if there were html tags in the string, it didnt close the tags.
<snip example>
> Basically this can leave bad html code that will not validate.
> After a morning of programming, I have made this code correctly close

> open html tags (ignores self closed tags) and treat html entites as
> character.

This isn't a half bad idea, except that it leads to strings that can be
quite a bit longer than the x characters implied in a [filter x]... tag.
 This patch makes [filter x] effectively useless for limiting the length
of code that might need its size limited. 

> Examples:
> [filter 20.]The sheep the sheep theyre gaining on me![/filter] = 'The

> sheep the sheep &hellip;'

This one would be fine if you replaced '20.' with '20'

> [filter 20.]The sheep <strong>the sheep theyre gaining on 
> me</strong>![/filter] = 'The sheep <strong>the sheep

This one, though, would lead to a string around 45 characters long. 
Kinda defeats the purpose of limiting the size to 20 characters.

And a pathological example of my own....

[filter 10]<strong>T</strong><strong>h</strong><strong>e</strong>

which--if your examples are right--won't chop anything at all, even
though the content is nearly 15 times as long as i'd expect it to be.

I would suggest that you separate the checks, so that /^(\d+)\.$/ and
/^(\d+)$/ are checked separately.  Unless there's a dot, the filter
should act as it did before; that is, chop off any characters after the
x'th, even if it involves breaking HTML tags.  Otherwise, any code that
relies on it to limit a field's real length might run into trouble.

BTW....that sure is a lot of code.  :)

More information about the interchange-users mailing list