mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-08 10:01:53 +00:00
LibWeb: Escape "<" and ">" when serializing attribute values
See https://github.com/whatwg/html/pull/6362
This commit is contained in:
parent
fbc56f74bd
commit
f1eaecc630
Notes:
github-actions[bot]
2025-05-22 06:56:41 +00:00
Author: https://github.com/Gingeh
Commit: f1eaecc630
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4839
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 7 additions and 6 deletions
|
@ -4698,14 +4698,15 @@ static String escape_string(StringView string, AttributeMode attribute_mode)
|
|||
// 2. Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string " ".
|
||||
else if (code_point == 0xA0)
|
||||
builder.append(" "sv);
|
||||
// 3. If the algorithm was invoked in the attribute mode, replace any occurrences of the """ character by the string """.
|
||||
// 3. Replace any occurrences of the "<" character by the string "<".
|
||||
else if (code_point == '<')
|
||||
builder.append("<"sv);
|
||||
// 4. Replace any occurrences of the ">" character by the string ">".
|
||||
else if (code_point == '>')
|
||||
builder.append(">"sv);
|
||||
// 5. If the algorithm was invoked in the attribute mode, then replace any occurrences of the """ character by the string """.
|
||||
else if (code_point == '"' && attribute_mode == AttributeMode::Yes)
|
||||
builder.append("""sv);
|
||||
// 4. If the algorithm was not invoked in the attribute mode, replace any occurrences of the "<" character by the string "<", and any occurrences of the ">" character by the string ">".
|
||||
else if (code_point == '<' && attribute_mode == AttributeMode::No)
|
||||
builder.append("<"sv);
|
||||
else if (code_point == '>' && attribute_mode == AttributeMode::No)
|
||||
builder.append(">"sv);
|
||||
else
|
||||
builder.append_code_point(code_point);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue