XoopsCore icon indicating copy to clipboard operation
XoopsCore copied to clipboard

Xoops_Locale_Abstract::substr

Open zyspec opened this issue 7 years ago • 0 comments

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:

  1. Always strip HTML entities then return the $length string.
  2. Strip HTML first if the rendered string is longer than $length, otherwise return HTML string.
  3. 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.

zyspec avatar Apr 17 '17 18:04 zyspec