Skip to content

Commit e54046d

Browse files
committed
#72 Fix escaped quote in SCE_JSON_URI and SCE_JSON_LDKEYWORD.
Duplicated '\' handling from SCE_JSON_STRING and SCE_JSON_PROPERTYNAME. Should appear same as when escape appears in a string without a URI or keyword.
1 parent b51fa52 commit e54046d

18 files changed

+139
-0
lines changed

doc/LexillaHistory.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,18 @@ <h2>Contributors</h2>
597597
</tr>
598598
</table>
599599
<h2 id="Releases">Releases</h2>
600+
<h3>
601+
<a href="https://www.scintilla.org/lexilla548.zip">Release 5.4.8</a>
602+
</h3>
603+
<ul>
604+
<li>
605+
Released 25 February 2026.
606+
</li>
607+
<li>
608+
JSON: Fix escaped quote in SCE_JSON_URI.
609+
<a href="https://github.com/ScintillaOrg/lexilla/issues/72">Issue #72</a>.
610+
</li>
611+
</ul>
600612
<h3>
601613
<a href="https://www.scintilla.org/lexilla547.zip">Release 5.4.7</a>
602614
</h3>

lexers/LexJSON.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,14 @@ void SCI_METHOD LexerJSON::Lex(Sci_PositionU startPos,
373373
}
374374
if (context.ch == '"') {
375375
context.ForwardSetState(SCE_JSON_DEFAULT);
376+
} else if (context.ch == '\\') {
377+
if (options.escapeSequence) {
378+
context.SetState(SCE_JSON_ESCAPESEQUENCE);
379+
if (!escapeSeq.newSequence(context.chNext)) {
380+
context.SetState(SCE_JSON_ERROR);
381+
}
382+
}
383+
context.Forward();
376384
} else if (context.atLineEnd) {
377385
context.ChangeState(SCE_JSON_STRINGEOL);
378386
}

test/examples/json/SciTE.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ lexer.json.allow.comments=1
1212
fold=1
1313
fold.compact=1
1414

15+
match *_0.json
16+
lexer.json.escape.sequence=0
17+

test/examples/json/embedded_0.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"k": "v",
3+
"value": "{\"k\":\"v\",\"list\":[{\"url\":\"https://domain.com/bin\"}]}"
4+
"value": "{\"k\":\"v\",\"list\":[{\"url\":\"@id\"}]}"
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2 400 401 + {
2+
0 401 401 | "k": "v",
3+
0 401 401 | "value": "{\"k\":\"v\",\"list\":[{\"url\":\"https://domain.com/bin\"}]}"
4+
0 401 401 | "value": "{\"k\":\"v\",\"list\":[{\"url\":\"@id\"}]}"
5+
0 401 400 | }
6+
0 400 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{8}{{0}
2+
{4}"k"{8}:{0} {2}"v"{8},{0}
3+
{4}"value"{8}:{0} {2}"{\"k\":\"v\",\"list\":[{\"url\":\"{9}https://domain.com/bin{2}\"}]}"{0}
4+
{4}"value"{8}:{0} {2}"{\"k\":\"v\",\"list\":[{\"url\":\"{12}@id{2}\"}]}"{0}
5+
{8}}{0}

test/examples/json/embedded_1.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"k": "v",
3+
"value": "{\"k\":\"v\",\"list\":[{\"url\":\"https://domain.com/bin\"}]}"
4+
"value": "{\"k\":\"v\",\"list\":[{\"url\":\"@id\"}]}"
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2 400 401 + {
2+
0 401 401 | "k": "v",
3+
0 401 401 | "value": "{\"k\":\"v\",\"list\":[{\"url\":\"https://domain.com/bin\"}]}"
4+
0 401 401 | "value": "{\"k\":\"v\",\"list\":[{\"url\":\"@id\"}]}"
5+
0 401 400 | }
6+
0 400 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{8}{{0}
2+
{4}"k"{8}:{0} {2}"v"{8},{0}
3+
{4}"value"{8}:{0} {2}"{{5}\"{2}k{5}\"{2}:{5}\"{2}v{5}\"{2},{5}\"{2}list{5}\"{2}:[{{5}\"{2}url{5}\"{2}:{5}\"{2}https://domain.com/bin{5}\"{2}}]}"{0}
4+
{4}"value"{8}:{0} {2}"{{5}\"{2}k{5}\"{2}:{5}\"{2}v{5}\"{2},{5}\"{2}list{5}\"{2}:[{{5}\"{2}url{5}\"{2}:{5}\"{2}@id{5}\"{2}}]}"{0}
5+
{8}}{0}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"k": "v",
3+
"list": [
4+
{
5+
"url": "https://domain.com/bin"
6+
"url": "@id"
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)