SauronEye icon indicating copy to clipboard operation
SauronEye copied to clipboard

Matches returned twice due to double foreach

Open martinsohn opened this issue 3 years ago • 1 comments

Here one keyword ("superunique") is given, and the single instance of the keyword is returned: image

Here two keywords ("superunique" and "stringtwo") are given, and the single instance of the first keyword is returned twice: image

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

martinsohn avatar Sep 22 '21 21:09 martinsohn

Thanks for reporting this issue @MartinSohn, I need to further investigate when I have some more time.

vivami avatar Sep 25 '21 17:09 vivami