Skip tracking tag level when inside script or style content.

This commit is contained in:
Brent Simmons committed 2025-10-21 10:14:35 -07:00
1 parent 7bb2c79f55
commit e19beb65cd
1 file changed
+6 -2
@@ -62,7 +62,10 @@ size_t stripHTML(const char *input, size_t inputLength,
// Handle tag opening
if (c == '<') {
tagLevel++;
// Only track tag level when not inside script/style
if (!inScript && !inStyle) {
tagLevel++;
}
// Check for script or style tags
if (in + 7 < inEnd && matchesTag(in + 1, "script")) {
@@ -102,7 +105,8 @@ size_t stripHTML(const char *input, size_t inputLength,
// Handle tag closing
if (c == '>') {
if (tagLevel > 0) {
// Only track tag level when not inside script/style
if (!inScript && !inStyle && tagLevel > 0) {
tagLevel--;
}
in++;