mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-08 02:11:35 +00:00
fix: harden browse cursor validation
This commit is contained in:
parent
36170d0fcb
commit
f24bd19cb7
2 changed files with 33 additions and 2 deletions
|
|
@ -40,4 +40,23 @@ describe('libraryBrowseCursor', () => {
|
|||
values: ['Dune']
|
||||
}))).to.throw('tie-breaker')
|
||||
})
|
||||
|
||||
it('rejects a cursor when the id tie-breaker value is null', () => {
|
||||
expect(() => decodeBrowseCursor(encodeBrowseCursor({
|
||||
sortBy: 'media.metadata.title',
|
||||
desc: false,
|
||||
keys: ['titleIgnorePrefix', 'id'],
|
||||
values: ['Dune', null]
|
||||
}))).to.throw('tie-breaker')
|
||||
})
|
||||
|
||||
it('rejects a malformed cursor string with a controlled invalid-cursor error', () => {
|
||||
expect(() => decodeBrowseCursor('%%%not-base64%%%')).to.throw('Invalid browse cursor')
|
||||
})
|
||||
|
||||
it('rejects malformed cursor json with a controlled invalid-cursor error', () => {
|
||||
const malformedJsonCursor = Buffer.from('{"sortBy":', 'utf8').toString('base64url')
|
||||
|
||||
expect(() => decodeBrowseCursor(malformedJsonCursor)).to.throw('Invalid browse cursor')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue