@balena/odata-parser 4.3.17 → 4.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.versionbot/CHANGELOG.yml +18 -1
- package/CHANGELOG.md +5 -0
- package/odata-parser.js +12 -2
- package/odata-parser.pegjs +12 -2
- package/package.json +2 -2
- package/test/encoding.ts +20 -0
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
- commits:
|
|
2
|
+
- subject: Report malformed percent-encoding as a `SyntaxError`
|
|
3
|
+
hash: b9897ab7edd7132227c7d6895e835f2ef345914e
|
|
4
|
+
body: |
|
|
5
|
+
`Text` and `QuotedText` call `decodeURIComponent`, which throws a
|
|
6
|
+
`URIError` for malformed escapes such as `%ZZ` or a truncated UTF-8
|
|
7
|
+
sequence. That error escaped the parser as-is, so a request like
|
|
8
|
+
`/resource?foo=%ZZ` or `$filter=name eq '%ZZ'` did not fail with the
|
|
9
|
+
parser's expected `SyntaxError`. This meant that downstream would
|
|
10
|
+
return a 500 error rather than the expected 400
|
|
11
|
+
footer:
|
|
12
|
+
Change-type: patch
|
|
13
|
+
change-type: patch
|
|
14
|
+
author: Pagan Gazzard
|
|
15
|
+
version: 4.3.18
|
|
16
|
+
title: ""
|
|
17
|
+
date: 2026-10-14T16:21:28.619Z
|
|
1
18
|
- commits:
|
|
2
19
|
- subject: Accept duration literals with zero-valued parts
|
|
3
20
|
hash: 0b55520089659a96b2565d237757adbd4c7ea031
|
|
@@ -18,7 +35,7 @@
|
|
|
18
35
|
author: Pagan Gazzard
|
|
19
36
|
version: 4.3.17
|
|
20
37
|
title: ""
|
|
21
|
-
date: 2026-10-14T16:
|
|
38
|
+
date: 2026-10-14T16:10:57.346Z
|
|
22
39
|
- commits:
|
|
23
40
|
- subject: Only merge `and`/`or` chains into n-ary filter nodes
|
|
24
41
|
hash: 01c5cf69787bc8ead551a37f3495d364ff8e1b7f
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
|
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
# v4.3.18
|
|
8
|
+
## (2026-10-14)
|
|
9
|
+
|
|
10
|
+
* Report malformed percent-encoding as a `SyntaxError` [Pagan Gazzard]
|
|
11
|
+
|
|
7
12
|
# v4.3.17
|
|
8
13
|
## (2026-10-14)
|
|
9
14
|
|
package/odata-parser.js
CHANGED
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
// `decodeURIComponent` throws a `URIError` for malformed input such as `%ZZ`, this reports it as a parse error
|
|
9
|
+
// instead, using peggy's `error` function, so callers can tell bad input apart from internal failures
|
|
10
|
+
function decodeURIComponentOrError(text, error) {
|
|
11
|
+
try {
|
|
12
|
+
return decodeURIComponent(text);
|
|
13
|
+
} catch {
|
|
14
|
+
error('Malformed percent-encoding');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
const methods = new Map(Object.entries({
|
|
9
19
|
cast: [ 1, 2 ],
|
|
10
20
|
ceiling: 1,
|
|
@@ -519,10 +529,10 @@ function peg$parse(input, options) {
|
|
|
519
529
|
second: time?.second,
|
|
520
530
|
} }
|
|
521
531
|
function peg$f85(d) { return Number(d) }
|
|
522
|
-
function peg$f86(text) { return
|
|
532
|
+
function peg$f86(text) { return decodeURIComponentOrError(text, error) }
|
|
523
533
|
function peg$f87() { return '+' }
|
|
524
534
|
function peg$f88() { return '\'' }
|
|
525
|
-
function peg$f89(text) { return
|
|
535
|
+
function peg$f89(text) { return decodeURIComponentOrError(text.join(''), error) }
|
|
526
536
|
function peg$f90(param) { return { bind: '@' + param } }
|
|
527
537
|
function peg$f91(n) { return Bind(['Real', n]) }
|
|
528
538
|
function peg$f92(n) { return Bind(['Integer', n]) }
|
package/odata-parser.pegjs
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
{{
|
|
2
|
+
// `decodeURIComponent` throws a `URIError` for malformed input such as `%ZZ`, this reports it as a parse error
|
|
3
|
+
// instead, using peggy's `error` function, so callers can tell bad input apart from internal failures
|
|
4
|
+
function decodeURIComponentOrError(text, error) {
|
|
5
|
+
try {
|
|
6
|
+
return decodeURIComponent(text);
|
|
7
|
+
} catch {
|
|
8
|
+
error('Malformed percent-encoding');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
2
12
|
const methods = new Map(Object.entries({
|
|
3
13
|
cast: [ 1, 2 ],
|
|
4
14
|
ceiling: 1,
|
|
@@ -620,7 +630,7 @@ DurationNumber =
|
|
|
620
630
|
Text =
|
|
621
631
|
// This regex is equivalent to `(!ReservedUriComponent)`
|
|
622
632
|
text:$[^:/?#\[\]@!$*&()+,;=]*
|
|
623
|
-
{ return
|
|
633
|
+
{ return decodeURIComponentOrError(text, error) }
|
|
624
634
|
|
|
625
635
|
Sign =
|
|
626
636
|
'+'
|
|
@@ -647,7 +657,7 @@ QuotedText =
|
|
|
647
657
|
Apostrophe @Apostrophe
|
|
648
658
|
)*
|
|
649
659
|
Apostrophe
|
|
650
|
-
{ return
|
|
660
|
+
{ return decodeURIComponentOrError(text.join(''), error) }
|
|
651
661
|
|
|
652
662
|
ParameterAlias =
|
|
653
663
|
'@' param:ResourceName
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/odata-parser",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.18",
|
|
4
4
|
"description": "An OData parser written in OMeta",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "odata-parser.js",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"npm": ">=8.1.0"
|
|
41
41
|
},
|
|
42
42
|
"versionist": {
|
|
43
|
-
"publishedAt": "2026-10-14T16:
|
|
43
|
+
"publishedAt": "2026-10-14T16:21:28.710Z"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/test/encoding.ts
CHANGED
|
@@ -13,4 +13,24 @@ describe('Encoding', function () {
|
|
|
13
13
|
assert(result instanceof SyntaxError);
|
|
14
14
|
}),
|
|
15
15
|
);
|
|
16
|
+
|
|
17
|
+
for (const input of [
|
|
18
|
+
'foo=%ZZ',
|
|
19
|
+
'@%ZZ=1',
|
|
20
|
+
"$filter=Foo eq '%ZZ'",
|
|
21
|
+
// A truncated multi-byte sequence
|
|
22
|
+
"$filter=Foo eq '%E0%A4%A'",
|
|
23
|
+
]) {
|
|
24
|
+
test(input, (result) =>
|
|
25
|
+
it('should fail with a SyntaxError for malformed percent-encoding', () => {
|
|
26
|
+
assert(result instanceof SyntaxError);
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
test.raw("/model('%ZZ')", (result) =>
|
|
32
|
+
it('should fail with a SyntaxError for malformed percent-encoding in a key', () => {
|
|
33
|
+
assert(result instanceof SyntaxError);
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
16
36
|
});
|