Commit 1d654c4
committed
fix(json-parse): scope code-context guard to candidate path suffix
Narrows the looksLikeWindowsPathPrefix code-context rejection from
scanning the entire 160-character tail to checking only the candidate
drive-path match and its immediate predecessor:
1. Reject when the non-alphanumeric separator before the drive letter
is a bracket or brace — real paths never start with (X: or {X:.
2. Reject when a block-opening keyword (as, if, in, for, def, etc.)
immediately precedes the candidate — 'as f:', 'if r:', 'in d:'
are code colons, not drive letters.
This preserves Windows path repair when code punctuation appears
earlier in the same string value (e.g. python -c 'x'; C:\new).
The keyword boundary check uses (?:^|[^A-Za-z0-9]|\\[nrt]) instead
of \b because stringValuePrefix tracks prior escapes in their literal
textual form — a decoded \n is stored as the two characters \ and n,
so keywords starting a new line (like 'if' after a newline) are
preceded by 'n' (alphanumeric), not whitespace.
Adds regression coverage for code-before-path ordering.
Refs #93139
Signed-off-by: Jakub Rusz <[email protected]>1 parent e58153b commit 1d654c4
2 files changed
Lines changed: 54 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 113 | + | |
| 114 | + | |
120 | 115 | | |
121 | 116 | | |
122 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
123 | 154 | | |
124 | 155 | | |
125 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
| |||
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
97 | 112 | | |
0 commit comments