Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException issues #43

Closed
ethauvin opened this issue May 29, 2017 · 7 comments
Closed

ArrayIndexOutOfBoundsException issues #43

ethauvin opened this issue May 29, 2017 · 7 comments
Assignees
Labels

Comments

@ethauvin
Copy link

Both:

Hashids hashids = new Hashids("this is my salt");
long[] numbers = hashids.decode("0");

and:

Hashids hashids = new Hashids("this is my salt");
long[] numbers = hashids.decode("test.txt");

are causing exceptions in various places.

I realize that they are not valid hashes, but the exception should either be declared or handled.

Hope this helps.

@Ramblurr
Copy link

I also ran into this today for the first time.

I definitely think that ArrayIndexOutOfBoundsException isn't the appropriate exception to throw. An IllegalArgumentException with an error message would be consistent with other exceptions thrown by the library.

@0x3333
Copy link
Collaborator

0x3333 commented May 29, 2017

I'll check on these today. I'll keep you posted on that.

@0x3333 0x3333 added the bug label May 29, 2017
@0x3333 0x3333 self-assigned this May 29, 2017
0x3333 added a commit that referenced this issue May 29, 2017
@0x3333
Copy link
Collaborator

0x3333 commented May 29, 2017

I fixed it.

Instead throwing an exception, I return an empty array []. This is the same behavior of the original library(Javascript).

@0x3333 0x3333 closed this as completed May 29, 2017
@kmandeville
Copy link

I have found two other occurrences where I get ArrayIndexOutOfBoundsException from deep in the HashIds code.
Hashids hashids = new Hashids("this is my salt"); long[] numbers = hashids.decode("[]");

and

Hashids hashids = new Hashids("this is my salt"); long[] numbers = hashids.decode("()");

Like the original submitter above, these aren't valid hashes, but I'm running into these errors in my web app because someone COULD put these characters in as an ID in a URL accidentally or on purpose. My app is just passing in these characters directly into HashIds. I would expect something other than ArrayIndexOutOfBoundsExceptions.

Please let me know if I should open a new bug. I figured this is directly related to this issue so I'd comment here.

@0x3333
Copy link
Collaborator

0x3333 commented Jun 10, 2017

Hi @kmandeville , I'll look at this issue, but for the sake of organization, could you file another issue? Just to relate it in the commit.
I'll get to work on it right away
Thanks.

@0x3333
Copy link
Collaborator

0x3333 commented Jun 10, 2017

@kmandeville , never mind, I just created it(Issue #45) and fixed in master.

Thanks!

@kmandeville
Copy link

Thank you!

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

No branches or pull requests

4 participants