mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Preserve opening quotation in string token original source text
Used by chess.com, where it stores URLs to assets in CSS URL variables. It then receives the value of them with getComputedStyle() and then getPropertyValue(). With this, it trims off the url('') wrapper with a simple slice(5, -2). Since we didn't preserve the opening quotation, it would slice off the `h` in `https` instead of the quotation.
This commit is contained in:
parent
a5e4a51b52
commit
d3057a9c79
Notes:
github-actions[bot]
2025-02-05 16:03:08 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/d3057a9c796 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3466 Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 17 additions and 3 deletions
|
@ -919,13 +919,13 @@ Token Tokenizer::consume_string_token(u32 ending_code_point)
|
|||
// code point is used.
|
||||
|
||||
// Initially create a <string-token> with its value set to the empty string.
|
||||
auto start_byte_offset = current_byte_offset();
|
||||
auto original_source_text_start_byte_offset_including_quotation_mark = current_byte_offset() - 1;
|
||||
auto token = create_new_token(Token::Type::String);
|
||||
StringBuilder builder;
|
||||
|
||||
auto make_token = [&]() -> Token {
|
||||
token.m_value = builder.to_fly_string_without_validation();
|
||||
token.m_original_source_text = input_since(start_byte_offset);
|
||||
token.m_original_source_text = input_since(original_source_text_start_byte_offset_including_quotation_mark);
|
||||
return token;
|
||||
};
|
||||
|
||||
|
@ -950,7 +950,7 @@ Token Tokenizer::consume_string_token(u32 ending_code_point)
|
|||
// <bad-string-token>, and return it.
|
||||
reconsume_current_input_code_point();
|
||||
auto bad_string_token = create_new_token(Token::Type::BadString);
|
||||
bad_string_token.m_original_source_text = input_since(start_byte_offset);
|
||||
bad_string_token.m_original_source_text = input_since(original_source_text_start_byte_offset_including_quotation_mark);
|
||||
return bad_string_token;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
style.getPropertyValue("--test-url") = url('https://ladybird.org/')
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
:root {
|
||||
--test-url: url('https://ladybird.org/');
|
||||
}
|
||||
</style>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const style = getComputedStyle(document.documentElement);
|
||||
println(`style.getPropertyValue("--test-url") = ${style.getPropertyValue("--test-url")}`);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Reference in a new issue