fix(backend/sdoc_source_code): let lark scan CR to NEWLINE, not to NODE_STRING_VALUE #2575
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#2554 added dedent logic, #2555 added hash generation. Tests revealed that hash results for same input were different on Windows and Linux even if CR LF was normalized to LF.
Further investigation revealed that dedent logic didn't work as expected on Windows, because CR LF got split half into the string token, and half into the newline token, which in turn confused the dedent logic. By trial it turned out that
"/[^\n\r]+/x"(verbose regex mode, normal string => real newlines) is not the same as"/[^\\n\\r]+/"(normal regex mode, normal string but escaped backslash => symbolized newlines). The former wrongly lets lark scan a \r into NODE_STRING_VALUE.Thus change to the latter pattern. Note: This fixes only the dedent issue. Hash generation still expects bit-wise identical input and tests would fail if expected hash was sampled on Linux but git converted input
\nto\r\non Windows. We need to re-addcode = code.replace(b"\r\n", b"\n")if hash shall be agnostic to line endings.