You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've ended up in a scenario where Decode method throws an exception when we pass any of the characters in the "guard" generated by SetupGuards method.
There's how you reproduce:
// this generates the following guards: rKEavarhashids=new Hashids("please fix me <3",15);// passing any of the chars defined in the guard may throw and exceptionActioninvocation=()=> hashids.Decode("a");
invocation.ShouldThrow<IndexOutOfRangeException>();
And here's what happens in GetNumbersFrom(string hash) method, please find below:
(...)// by passing a guard char this replace fails to add a separator (" ")
var hashBreakdown = guardsRegex.Replace(hash,"");// hashArray will be empty since there's no " " to split..varhashArray= hashBreakdown.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);if(hashArray.Length ==3|| hashArray.Length ==2)i=1;// ...and this line fails.hashBreakdown= hashArray[i];
I'm not sure what the guards stands for in that case (didn't made much effort there, eh) but I believe that's not how it's supposed to behave.
Kind regards,
Pedro.
The text was updated successfully, but these errors were encountered:
Hey! I'll have a look!
But I think I will change the logic around how to setup the alphabet (see issue #20) and guards...
Thanks for the code, I'll make a test and see if it is something I should change!
@ullmark Any update on this? We've surrounded our decode checks with a try/catch for IndexOutOfRangeExceptions in the meantime but would prefer a proper solution.
Hi @ullmark ,
I've ended up in a scenario where Decode method throws an exception when we pass any of the characters in the "guard" generated by SetupGuards method.
There's how you reproduce:
And here's what happens in GetNumbersFrom(string hash) method, please find below:
I'm not sure what the guards stands for in that case (didn't made much effort there, eh) but I believe that's not how it's supposed to behave.
Kind regards,
Pedro.
The text was updated successfully, but these errors were encountered: