Repository navigation
Commit f762d6c
committed
Fix XPath unary minus parsing with leading or separating spaces
`UnaryExpr` did not strip leading spaces before matching `-` or allow
spaces between multiple `-` operators, and `PathExpr` / `LocationPath`
stripped leading spaces even when they did not match anything. As a
result, unary minus expressions with spaces such as `" -6"` or `"- - 6"`
were misinterpreted by `AdditiveExpr` as a binary subtraction
(`[:minus, [], [:literal, 6]]` or `[:minus, [:neg], [:literal, 6]]`).
After #318 removed the `gsub!(/([\(\[])\s+/, '\1')` preprocessing in
`parse`, this also affected expressions after `(` or `[` such as
`"( -6 )"` and `"//v[ -1 ]"`.
- Strip leading spaces in `UnaryExpr` and allow spaces between multiple
`-` operators.
- Restore `original_path` in `UnaryExpr`, `PathExpr`, and `LocationPath`
when no expression matches.1 parent b777bdf commit f762d6c
3 files changed
Lines changed: 40 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
| |||
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
267 | 273 | | |
268 | | - | |
269 | 274 | | |
270 | 275 | | |
271 | 276 | | |
| |||
564 | 569 | | |
565 | 570 | | |
566 | 571 | | |
567 | | - | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
568 | 575 | | |
569 | | - | |
| 576 | + | |
570 | 577 | | |
571 | 578 | | |
572 | 579 | | |
573 | 580 | | |
574 | 581 | | |
575 | 582 | | |
576 | 583 | | |
577 | | - | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
578 | 589 | | |
579 | | - | |
| 590 | + | |
580 | 591 | | |
581 | 592 | | |
582 | 593 | | |
| |||
601 | 612 | | |
602 | 613 | | |
603 | 614 | | |
| 615 | + | |
604 | 616 | | |
605 | 617 | | |
606 | 618 | | |
607 | 619 | | |
608 | 620 | | |
| 621 | + | |
609 | 622 | | |
610 | 623 | | |
611 | 624 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
183 | 195 | | |
184 | 196 | | |
185 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
225 | 235 | | |
226 | 236 | | |
227 | 237 | | |
| |||
0 commit comments