mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 12:14:22 +01:00
Because `segment.adjustMatchIndex(matchIndex)` was above `segment.lineEndIndex(currentRaw, matchIndex[1]-matchIndex[0])` there were cases where it would cause an out of bounds error. This change resolves the issue by just assuming the whole segment is a opaque chunk of text and starts at the boundaries of the segment instead so that the order doesn't matter as much. The other option would have been to reorder the assignments and add tests to account for that case, but I figured this option is less likely to have gotchas when working with different encoding formats at the potential expense of getting an extra line or two if an encoding format in the future ever allows multiple lines of encoded content to be considered a single segment.