fix: фикс креативов
This commit is contained in:
@@ -252,16 +252,33 @@ 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user