Skip to content

wrong boolean expression#23

Closed
serprime wants to merge 2 commits into
scribejava:masterfrom
serprime:master
Closed

wrong boolean expression#23
serprime wants to merge 2 commits into
scribejava:masterfrom
serprime:master

Conversation

@serprime

Copy link
Copy Markdown

hi pablo,

there was a wrong boolean expression in OAuthRequest.java:
in checkKey(String key):
(!key.startsWith(OAUTH_PREFIX) || !key.equals(OAuthConstants.SCOPE)
it returns true for all keys that do not contain "oauth_".

btw, nice library - like it.

…ption: OAuth parameters must either be scope or start with 'oauth_')
…ption: OAuth parameters must either be scope or start with 'oauth_')... really now
@fernandezpablo85

Copy link
Copy Markdown
Collaborator

Dude,

The bug is actually fixed since this morning on "master".

Thanks anyway for the patches and the kind words :D

@serprime

Copy link
Copy Markdown
Author

But I get an exception anyway for scope.

the expression becomes true for every key that does not start with "oauth_", also for "scope".

@fernandezpablo85

Copy link
Copy Markdown
Collaborator

If you use the JAR, yes it will fail.

To get the fix you need to download and build from source

@serprime

Copy link
Copy Markdown
Author

i cloned the repo with git, included the package from src/main/java, tried:

OAuthService service = new ServiceBuilder()
.provider(GoogleApi.class)
.apiKey(apiKey)
.apiSecret(apiSecret)
.callback(callbackURL)
.scope(scope)
.build();

and got the "OAuth parameters must either be scope or start with 'oauth_'" exception.

i'm pretty sure that the if becomes true for each key that does not start with "oauth_", but it should be false if it is/starts with "scope", right?

not ("scope" startsWith("oauth_")) == true,
and (true || anything) is true

@fernandezpablo85

Copy link
Copy Markdown
Collaborator

Get 1.0.7

It's fixed there. Sorry for the trouble, you were right all the way

@serprime

Copy link
Copy Markdown
Author

there were no trouble ;)
i liked it - that was the first time for me to look under the hood of an foreign library

@fernandezpablo85

Copy link
Copy Markdown
Collaborator

Very glad to hear that :)

Hopefully the code was an easy (or at least not very difficult) read.

Thanks!

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants