fix: фикс креативов

This commit is contained in:
Artem Tsyrulnikov
2026-02-11 15:55:15 +03:00
parent 1940386786
commit be7d1fe851

View File

@@ -252,15 +252,32 @@ func normalizeHTMLTags(input string) string {
continue
}
if isClosing {
if len(stack) > 0 && stack[len(stack)-1] == tagName {
stack = stack[:len(stack)-1]
out.WriteString(input[i : end+1])
if isClosing {
// Find the tag in stack
foundIndex := -1
for j := len(stack) - 1; j >= 0; j-- {
if stack[j] == tagName {
foundIndex = j
break
}
} else {
stack = append(stack, tagName)
out.WriteString(input[i : end+1])
}
if foundIndex >= 0 {
// Close all tags from top of stack down to foundIndex
for j := len(stack) - 1; j > foundIndex; j-- {
out.WriteString("</")
out.WriteString(stack[j])
out.WriteString(">")
}
// Close the found tag
out.WriteString(input[i : end+1])
// Remove closed tags from stack
stack = stack[:foundIndex]
}
} else {
stack = append(stack, tagName)
out.WriteString(input[i : end+1])
}
i = end + 1
}