Asana / locheck

Validate iOS, Android, and Mac localizations. Find errors in .strings, .stringsdict, and strings.xml files.
MIT License
96 stars 10 forks source link

Locheck hangs on some // comments #40

Open alex-hunsley-nl opened 1 year ago

alex-hunsley-nl commented 1 year ago

Locheck was hanging for me. I found out the problem was a line like this:

////////////////////////

I also found out that a line with a comment and no characters after the slashes has the same effect:

//

stevelandeyasana commented 1 year ago

I wrote a unit test for this but wasn't able to reproduce the issue. I also tried adding the lines to the demo .strings files and didn't see a hang. Can you provide a minimal example .strings file that has the problem?

The way this works under the hood is a simple regex match on each line. All I can think of is that the regex is taking a really long time, but I would think I'd be able to easily reproduce that.

alex-hunsley-nl commented 1 year ago

Hi Steve, thanks. Yes I think it's the regular expression matching then.

If one of my Localizable.strings files contains just this (with newline at the end) we start to get slow performance:

//////////////////////////////////////

If you add a few more /, it's slow enough to seem like it's hanged.