Topic: Problems after updating from 1.2.4 to 1.2.12
Hi,
I recently updated from 1.2.4 to 1.2.12 and had to modify htmLawed slightly to get our test suite working. Here are the issues I encountered:
(1) Depending on the “safe” configuration either ", app, javascript; *: data, javascript, file, http, https" or "; *: file, http, https” is appended to the end of the user-provided “schemes” configuration. The documentation doesn’t mention that anything will be appended to the config string so I assume this is a bug. It looks like an operator precedence/parentheses issue, potentially complicated by the ternary operator precedence changing between PHP 7 and 8:
$x = (isset($C['schemes'][2]) && strpos($C['schemes'], ':')
? strtolower($C['schemes'])
: 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, tel, telnet')
. (empty($C['safe'])
? ', app, javascript; *: data, javascript, '
: '; *:')
. 'file, http, https';
(2) Only <summary> is allowed as a child of <details> and all other tags are removed despite <details> supporting flow content. I believe this is happening because in hl_balance() the <details> element is listed in $validMomKidAr. It is also listed in $otherValidMomKidAr which seems like the correct place for it.
(3) A <br/> tag is stripped out but a <br /> with a space before the / is not stripped out. I believe this is happening due to a change in the regex used in hl_tag() which detects the end of the tag by looking for whitespace or >. Having it also stop on / appears to fix the problem.
(4) The <ruby> tag is not allowed to have text directly inside it. As a result an example from MDN:
<ruby>
明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp>
</ruby>
gets turned into
<ruby>
<rp>(</rp><rt>Ashita</rt><rp>)</rp>
</ruby>