SauronEye
SauronEye copied to clipboard
Matches returned twice due to double foreach
Here one keyword ("superunique") is given, and the single instance of the keyword is returned:
Here two keywords ("superunique" and "stringtwo") are given, and the single instance of the first keyword is returned twice:
The problem lies in that there's a foreach for keywords: https://github.com/vivami/SauronEye/blob/0019969cf846c76936493fa34c9a0343a7fe7478/src/SauronEye/Searcher.cs#L269
Which later for each keyword also runs a foreach for regexes: https://github.com/vivami/SauronEye/blob/0019969cf846c76936493fa34c9a0343a7fe7478/src/SauronEye/RegexSearch.cs#L39
Additionally, here setting 'res' is unnecessary as it is already set in RegexSearcher.GetIndexOfRegexPattern https://github.com/vivami/SauronEye/blob/0019969cf846c76936493fa34c9a0343a7fe7478/src/SauronEye/Searcher.cs#L287
Thanks for reporting this issue @MartinSohn, I need to further investigate when I have some more time.