Skip to content

Commit

Permalink
bugfix for endless loop with illegal input.
Browse files Browse the repository at this point in the history
  • Loading branch information
bangco committed Dec 13, 2020
1 parent d5c20b2 commit cfda914
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Base62x.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
}
else{
console.log('static decode: illegal base62x input:['+inputArr[i]+']. 1702122106.');
i++;
continue;
}
m++;
Expand Down
1 change: 1 addition & 0 deletions Base62x.class.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public static final class Base62x{
}
else{ //- == 1
System.out.println("Base62x.decode: illegal base62x input:["+input+"]. 1608091042.");
i++;
continue;
}
m++;
Expand Down
1 change: 1 addition & 0 deletions Base62x.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public static function decode($input, $obase=null){
}
else{
error_log(__FILE__.": found illegal base62x input:[".$inputArr[$i]."]. 1608091042.");
$i++;
continue;
}
$m++;
Expand Down
1 change: 1 addition & 0 deletions Base62x.pm
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ sub decode($ $){
}
elsif($remaini == 1){
print($LOGTAG.": found illegal base62x input:[".$inputArr[$i]."]. 1608091042.");
$i++;
next;
}
$m++;
Expand Down
1 change: 1 addition & 0 deletions Base62x.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def decode(self, encstr, obase=0):
elif remaini == 1:
print("{} found illegal input:[{}]. 1903091005. i:[{}]".format(
self.LogTag, inputArr[i], i))
i += 1
continue

m += 1
Expand Down
Binary file modified base62x
Binary file not shown.
1 change: 1 addition & 0 deletions base62x.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ int main(int argc, char *argv[]){
}
else{
printf("Base62x.decode: found illegal base62x input:[%s]! 1612121816.\n", input);
i++;
continue;
}
m++; //- deprecated.
Expand Down
16 changes: 16 additions & 0 deletions test4IssueFromHahaapi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

include("./Base62x.class.php");


$s = "中文测试";

print "enc: ".($senc=Base62x::encode($s))."\n";
print "dec-$senc: ".Base62x::decode($senc)."\n";
print "dec-vBYjvfQ7vhMBwAx2: ".Base62x::decode("vBYjvfQ7vhMBwAx2")."\n";
print "dec-vBYjvfQ7vhMBwAx: ".Base62x::decode("vBYjvfQ7vhMBwAx")."\n";
print "dec-vBYjvfQ7vhMBwA: ".Base62x::decode("vBYjvfQ7vhMBwA")."\n";
print "dec-vBYjvfQ7vhMBw: ".Base62x::decode("vBYjvfQ7vhMBw")."\n";
print "dec-vBYjvfQ7vhMB: ".Base62x::decode("vBYjvfQ7vhMB")."\n";

?>

0 comments on commit cfda914

Please sign in to comment.