summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Token.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-10-25 18:36:10 +0000
committerAndreas Kling <kling@serenityos.org>2020-10-25 19:45:47 +0100
commit66e315959d4b31d9162517ac6a8e9f85f37e7164 (patch)
tree872a31dc4e06357aec8e1a11e9453669828de892 /Libraries/LibJS/Token.cpp
parent1319ad476d882785e37ff49523aa41e9d09d9534 (diff)
downloadserenity-66e315959d4b31d9162517ac6a8e9f85f37e7164.zip
LibJS: Allow all line terminators to be used for line continuations
Diffstat (limited to 'Libraries/LibJS/Token.cpp')
-rw-r--r--Libraries/LibJS/Token.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Libraries/LibJS/Token.cpp b/Libraries/LibJS/Token.cpp
index 89a3b212ac..082e8ac9aa 100644
--- a/Libraries/LibJS/Token.cpp
+++ b/Libraries/LibJS/Token.cpp
@@ -157,6 +157,8 @@ String Token::string_value(StringValueStatus& status) const
break;
case '\n':
break;
+ case '\r':
+ break;
case 'x': {
if (i + 2 >= m_value.length() - offset)
return encoding_failure(StringValueStatus::MalformedHexEscape);
@@ -207,6 +209,14 @@ String Token::string_value(StringValueStatus& status) const
break;
}
default:
+ if (i + 2 < m_value.length() - offset) {
+ auto three_chars_view = m_value.substring_view(i, 3);
+ if (three_chars_view == LINE_SEPARATOR || three_chars_view == PARAGRAPH_SEPARATOR) {
+ // line continuation with LS or PS
+ i += 2;
+ break;
+ }
+ }
if (is_template && (m_value[i] == '$' || m_value[i] == '`')) {
builder.append(m_value[i]);
break;