[Webkit-unassigned] [Bug 276365] script.innerText interop issues with new lines
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Aug 6 00:38:07 PDT 2024
https://bugs.webkit.org/show_bug.cgi?id=276365
--- Comment #6 from Karl Dubost <karlcow at apple.com> ---
https://searchfox.org/wubkat/rev/b36cbce69fddb7da33823f316bd8ead5bebee970/Source/WebCore/html/HTMLScriptElement.cpp#112-135
HTMLScriptElement::setTextContent()
calls setTextContent(WTFMove(newValue));
https://searchfox.org/wubkat/rev/b36cbce69fddb7da33823f316bd8ead5bebee970/Source/WebCore/dom/Node.cpp#1774
HTMLScriptElement::setInnerText()
calls setInnerText(WTFMove(newValue));
https://searchfox.org/wubkat/rev/b36cbce69fddb7da33823f316bd8ead5bebee970/Source/WebCore/html/HTMLElement.cpp#542
These two are very different.
ExceptionOr<void> HTMLElement::setInnerText(String&& text)
{
// FIXME: This doesn't take whitespace collapsing into account at all.
if (!text.contains([](UChar c) { return c == '\n' || c == '\r'; })) {
stringReplaceAll(WTFMove(text));
return { };
}
if (isConnected() && isTextControlInnerTextElement()) {
if (!text.contains('\r')) {
stringReplaceAll(WTFMove(text));
return { };
}
String textWithConsistentLineBreaks = makeStringBySimplifyingNewLines(text);
stringReplaceAll(WTFMove(textWithConsistentLineBreaks));
return { };
}
// FIXME: This should use replaceAll(), after we fix that to work properly for DocumentFragment.
// Add text nodes and <br> elements.
Ref fragment = textToFragment(document(), WTFMove(text));
// It's safe to dispatch events on the new fragment since author scripts have no access to it yet.
ScriptDisallowedScope::EventAllowedScope allowedScope(fragment.get());
return replaceChildrenWithFragment(*this, WTFMove(fragment));
}
I wonder what
String textWithConsistentLineBreaks = makeStringBySimplifyingNewLines(text);
does to the string.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240806/06e71776/attachment.htm>
More information about the webkit-unassigned
mailing list