Skip to content

Commit 9c6a048

Browse files
committed
Correct a small issue that made it not really RFC6901 Compliant
1 parent 75365ec commit 9c6a048

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

general.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe('Various Test Cases', () => {
166166
})
167167

168168
it('is able to access "/" keys from above', async () => {
169-
for (const engine of [...normalEngines, ...permissiveEngines]) await testEngine(engine, { map: [[1], { '+': [{ var: '' }, { var: '../../..~1' }] }] }, { '': { '': { '/': 3 } } }, [4])
169+
for (const engine of [...normalEngines, ...permissiveEngines]) await testEngine(engine, { map: [[1], { '+': [{ var: '' }, { var: '../..////~1' }] }] }, { '': { '': { '/': 3 } } }, [4])
170170
})
171171

172172
it('is able to handle path escaping with multiple escapes', async () => {

suites/scopes.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"rule": {
5959
"map": [
6060
{ "var": "arr" },
61-
{ "+": [{ "var": "../../~2~2~1" }, { "var": "../../..~1" }]}
61+
{ "+": [{ "var": "../../~2~2~1" }, { "var": "../..////~1" }]}
6262
]
6363
},
6464
"data": { "arr": [1,2,3], "../": 10, "": { "": { "/": 7 }} },

suites/vars.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
"Test Specification for Handling esoteric path traversal",
33
{
44
"description": "Fetches a value from an empty key",
5-
"rule": { "var": "." },
5+
"rule": { "var": "/" },
66
"data": { "" : 1 },
77
"result": 1
88
},
99
{
1010
"description": "Fetches a value from a nested empty key",
11-
"rule": { "var": ".." },
11+
"rule": { "var": "//" },
1212
"data": { "" : { "": 2 } },
1313
"result": 2
1414
},
1515
{
1616
"description": "Fetches a value from a doubly nested empty key",
17-
"rule": { "var": "..." },
17+
"rule": { "var": "///" },
1818
"data": { "" : { "": { "": 3 } } },
1919
"result": 3
2020
},
@@ -38,13 +38,13 @@
3838
},
3939
{
4040
"description": "Fetches a value from a key inside an empty key with a dot in it",
41-
"rule": { "var": "/~2key" },
41+
"rule": { "var": "//~2key" },
4242
"data": { "": { ".key" : 6 } },
4343
"result": 6
4444
},
4545
{
4646
"description": "Going a few levels deep",
47-
"rule": { "var": "//~2key." },
47+
"rule": { "var": "///~2key/" },
4848
"data": { "": { "": { ".key": { "": 7 }} }},
4949
"result": 7
5050
},
@@ -62,7 +62,7 @@
6262
},
6363
{
6464
"description": "Empty key then dot",
65-
"rule": { "var": ".~2" },
65+
"rule": { "var": "//~2" },
6666
"data": { "" : { "." : 11 } },
6767
"result": 11
6868
},
@@ -79,20 +79,20 @@
7979
"result": 13
8080
},
8181
{
82-
"description": "Fetches a value from an empty key, traditional",
83-
"rule": { "var": "/" },
82+
"description": "Fetches a value from an empty key, equivalence",
83+
"rule": { "var": "." },
8484
"data": { "" : 1 },
8585
"result": 1
8686
},
8787
{
88-
"description": "Fetches a value from a nested empty key, traditional",
89-
"rule": { "var": "//" },
88+
"description": "Fetches a value from a nested empty key, equivalence",
89+
"rule": { "var": ".." },
9090
"data": { "" : { "": 2 } },
9191
"result": 2
9292
},
9393
{
94-
"description": "Fetches a value from a doubly nested empty key, traditional",
95-
"rule": { "var": "///" },
94+
"description": "Fetches a value from a doubly nested empty key, equivalence",
95+
"rule": { "var": "..." },
9696
"data": { "" : { "": { "": 3 } } },
9797
"result": 3
9898
}

utilities/splitPath.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function splitPath (str) {
4646
// The following else might be something tweaked in a spec.
4747
} else throw new Error('Invalid escape sequence')
4848
} else if (char === '.' || char === '/') {
49-
parts.push(current)
49+
if (i) parts.push(current)
5050
current = ''
5151
} else current += char
5252
}

0 commit comments

Comments
 (0)