Skip to content

Commit a9659a7

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(oracle-fusion): preserve self-link key whitespace
1 parent 4d644af commit a9659a7

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎apps/sim/lib/internal/oracle-fusion/protocol.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,26 @@ describe('Oracle self links', () => {
176176
).toBe(key)
177177
})
178178

179+
it('requires spaces in self-link keys to be encoded and preserves their value', () => {
180+
const key = 'person name '
181+
const encoded = encodeOracleFusionPathSegment(key)
182+
expect(encoded).toBe('person%20name%20')
183+
expect(
184+
extractOracleFusionOpaqueKey(
185+
resource(`${ORIGIN}${COLLECTION}/${encoded}`),
186+
ORIGIN,
187+
COLLECTION_ADDRESS
188+
)
189+
).toBe(key)
190+
expect(() =>
191+
extractOracleFusionOpaqueKey(
192+
resource(`${ORIGIN}${COLLECTION}/${key}`),
193+
ORIGIN,
194+
COLLECTION_ADDRESS
195+
)
196+
).toThrow('Oracle self link is malformed')
197+
})
198+
179199
it.each(['', ' ', '.', '..', 'a/b', 'a\\b', 'a?b', 'a#b', 'a\nb', 'x'.repeat(2049)])(
180200
'rejects the unsafe opaque key %j',
181201
(key) => {

‎apps/sim/lib/internal/oracle-fusion/protocol.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66

77
const OPAQUE_KEY_MAX_LENGTH = 2048
88
const UNSAFE_OPAQUE_KEY = /[\\/?#\u0000-\u001f\u007f]/
9-
const UNSAFE_SELF_LINK_TEXT = /[\u0000-\u001f\u007f]/
9+
const UNSAFE_SELF_LINK_TEXT = /[\s\u0000-\u001f\u007f]/
1010
const RAW_SELF_LINK_DOT_SEGMENT = /(?:^|[\\/])(?:\.|%2e){1,2}(?=[\\/?#]|$)/i
1111

1212
function hasWellFormedUtf16(value: string): boolean {

0 commit comments

Comments
 (0)