Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Fix query string hash with false parameters #12

Merged
merged 1 commit into from
Nov 29, 2019

Conversation

jvanraaij
Copy link
Contributor

When using the JWTClient to send a query with a parameter that has a value of '' or '0', the QSH and resulting JWT signature doesn't match and Atlassian rejects it with a 401.

An example might be using /rest/api/3/worklog/updated?since=0 to retrieve worklogs updated since the beginning of time. The current code to handle parameter-only query strings will accidentally activate on strings that are considered false in PHP, so it will be treated like it's just since. As a result, it hashes GET&/rest/api/3/worklog/updated&since instead of the expected GET&/rest/api/3/worklog/updated&since=0. The same problem also occurs if you send an empty parameter, like properties=.

This PR fixes the code to properly differentiate between ?param, ?param= and ?param=0 and adds some tests for these cases. According to the PHP docs on boolean casting, there shouldn't be any other string values that are considered false, so I think these tests are enough.

@breart breart changed the base branch from master to develop November 29, 2019 17:29
@breart breart changed the base branch from develop to hotfix/1.3.1 November 29, 2019 17:40
@breart breart merged commit b22bb85 into breart:hotfix/1.3.1 Nov 29, 2019
@breart
Copy link
Owner

breart commented Nov 29, 2019

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants