Remove regexes from compiled code#1197
Merged
Merged
Conversation
Regex literals are compiled into beam files, and the compiled PCRE pattern format is not portable across OTP versions. An archive built on OTP 28.1+ embeds patterns that load via :re.import/1, which does not exist on OTP <= 28.0, crashing with UndefinedFunctionError.
Keeps the compiled archive free of embedded regex patterns, which are not portable across OTP versions. User-supplied :exclude_patterns regexes are unaffected; they are built in the user's project at runtime and never embedded in Hex's beams.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Regex literals are compiled into beam files at compile time, and the compiled PCRE pattern format is not portable across OTP versions. An archive built on OTP 28.1+ embeds patterns that are reloaded via
:re.import/1, which does not exist on OTP <= 28.0, crashing with:(seen in https://github.com/elixir-lang/elixir/actions/runs/28501655392/job/84480157006)
Only two regexes existed in shipped code; both are replaced with plain pattern matching:
lib/hex/cooldown.ex:~r/\A(\d+)(d|w|mo)\z/becomesInteger.parse/1with a leading-digit guard. Behavior-identical, verified on 18 edge cases including"+5d","-5d","1_0d", whitespace, and non-ASCII digits; characterization tests added.lib/mix/tasks/hex.build.ex:~r/\W\.DS_Store$/becomesPath.basename(path) == ".DS_Store". User-supplied:exclude_patternsregexes still work since they are built in the user's project at runtime and never embedded in Hex's beams. Two intentional improvements: a root-level.DS_Storeis now excluded too, and files merely ending in.DS_Storeare no longer silently dropped.A new lint test rejects any
~r/Regex./:re.usage underlib/so regexes do not get reintroduced into the precompiled archive.