Page 1 of 1

Problems with HTML tag attributes and Glossary / Dictionary Page / FAQ Module

Posted: Wed Aug 30, 2006 12:38 pm
by nonty
Hi all,

I wish to use the "Activate all Terms on site?" option of the Glossary / Dictionary Page / FAQ Module. As I have a rather small site with only cacheable pages, the bad performance of the option is not an issue.

Unfortunately the current implementation of this option will try to add links in too many places of a page, most notably it will not ignore attribute values of HTML tags.

Consider if TERM is a defined term in the model and the page in question contains the following:

It is also possible to use TERM as an replacement (read more)...

In this case both instances of "TERM" will get linkified resulting in:

It is also possible to use TERM as an replacement (TERM?">read more)...

which is clearly not valid HTML.

I have tried with different regular expressions (involving negative prefixes and like), but none have worked properly until now.

I believe I can see a way out using preg_replace_callback, but before I go into this I want to hear if anybody else have seen this problem and (hopefully) solved it. Alternative modules could be an option too.

/tonny

Re: Problems with HTML tag attributes and Glossary / Dictionary Page / FAQ Modul

Posted: Tue Mar 27, 2007 1:58 pm
by Steppenwolf
Hi tonny,

here is a workaround (works only with western latin (ISO-8859-1) characters):

In the file Glossary.module.php, function CreateTermLink() replace the two occurrences of

addslashes(strip_tags($def))
with

htmlentities(substr(utf8_decode(strip_tags($def)),0,512))


I guess, this is not a perfect fix, but it works on my site.

Eberhard

Re: Problems with HTML tag attributes and Glossary / Dictionary Page / FAQ Modul

Posted: Tue Mar 27, 2007 5:41 pm
by nonty
Thanks for the tip. I will look into this when I get some time... /tonny