XoopsCore
XoopsCore copied to clipboard
Xoops_Locale_Abstract::substr
Enhancement
The substr() method has the probability of "breaking" HTML entities passed into the method if the input string is longer than the $length param. It seems there's 3 potential solutions:
- Always strip HTML entities then return the $length string.
- Strip HTML first if the rendered string is longer than $length, otherwise return HTML string.
- Use DOMElement object and sequentially cycle through the childNodes and add them to the returned string if the "length" of the rendered string is <= $length. Otherwise truncate the string at the end of the previous childNode. The string returned may end up shorter than the requested $length but at least it would render correctly.
This is also a potential issue in XOOPS 2.5.x XoopsLocalAbstract::substr() method.