mysql2sqlite
mysql2sqlite copied to clipboard
Hex number trimming is a potential endless loop
Converting a database hanged up for me. It seems that the following code was the culprit:
https://github.com/dumblob/mysql2sqlite/blob/d14d22ad7029cdf4d11825ee3c96922e8fbb0122/mysql2sqlite#L129-L133
This will hang up if the input contains two hex numbers, such as 0x1234567890ABCDEFABCDEF 0x1234567890ABCDEFABCDEF. Replacing sub() by gsub() fixes it for me.
Just realized that my change probably doesn’t do the right thing: it will trim all hex numbers regardless of length. So I think that the following should work correctly:
gsub( /0x[0-9a-fA-F]{17,}/, substr( $0, RSTART, RLENGTH-1 ), $0 )
This regexp will only match hex numbers with more than 16 characters.
Hi, thanks for the report! Yep, I'd try changing the regex to include {17,} at the end (of course no gsub but just sub) as you suggests. Does it seem to work? If so, could you make a PR with a unit test?
See other open PRs to get a glimpse where we're heading with unit testing. Unfortunately it's all not yet fully implemented as I'm totally out of time. So feel free to review also other PRs and I'll merge them. I'm actually considering finding some time to migrate this project under some org as it seems I won't have the time to properly maintain it further in the near future.
Thoughts?
A PR might take a while, I’m also quite out of time unfortunately…