mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb: Escape "<" and ">" when serializing attribute values
See https://github.com/whatwg/html/pull/6362
This commit is contained in:
Notes:
github-actions[bot]
2025-05-22 06:56:41 +00:00
Author: https://github.com/Gingeh Commit: https://github.com/LadybirdBrowser/ladybird/commit/f1eaecc6302 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4839 Reviewed-by: https://github.com/AtkinsSJ ✅
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user