Merge pull request #15473 from overleaf/jel-remove-encoded-hash

[web] Remove encoded hashtag when checking token hash prefix

GitOrigin-RevId: 2b9c369beceb7897d0f6f165b4c3a70b79c14469
This commit is contained in:
Jessica Lawshe 2023-10-30 08:52:12 -05:00 committed by Copybot
parent 3cd0cefd30
commit a3251394e1
2 changed files with 19 additions and 1 deletions

View file

@ -291,7 +291,7 @@ const TokenAccessHandler = {
let hashPrefixStatus let hashPrefixStatus
if (tokenHashPrefix) { if (tokenHashPrefix) {
tokenHashPrefix = tokenHashPrefix.replace('#', '') tokenHashPrefix = tokenHashPrefix.replace('#', '').replace('%23', '')
} }
if (!tokenHashPrefix) { if (!tokenHashPrefix) {

View file

@ -719,5 +719,23 @@ describe('TokenAccessHandler', function () {
} }
) )
}) })
it('it handles encoded hashtags', function () {
const token = 'zxpxjrwdtsgd'
const prefix = this.TokenAccessHandler.createTokenHashPrefix(token)
this.TokenAccessHandler.checkTokenHashPrefix(
token,
`%23${prefix}`,
'readOnly'
)
expect(this.Metrics.inc).to.have.been.calledWith(
'link-sharing.hash-check',
{
path: 'readOnly',
status: 'match',
}
)
})
}) })
}) })