Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5a954a5

Browse files
committedMay 18, 2024··
Respect Regexp.compile method signature
As far as I can tell, Regexp.compile has never accepted a third parameter to Regexp.compile until Ruby 3.2. There it actually is a timeout parameter. In older versions it was discarded as an invalid input. It's unclear to me if this parameter ever worked in the first place. This PR attemps to still make it work as it was originally intended, but it's unclear what the original goal even was.
1 parent 779595a commit 5a954a5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
 

‎lib/puppet/functions/regsubst.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,10 @@
5656
# - *I* Ignore case in regexps
5757
# - *M* Multiline regexps
5858
# - *G* Global replacement; all occurrences of the regexp in each target string will be replaced. Without this, only the first occurrence will be replaced.
59-
# @param encoding [Enum['N','E','S','U']]
59+
# @param encoding [Optional[Enum['N']]
6060
# Optional. How to handle multibyte characters when compiling the regexp (must not be used when pattern is a
6161
# precompiled regexp). A single-character string with the following values:
6262
# - *N* None
63-
# - *E* EUC
64-
# - *S* SJIS
65-
# - *U* UTF-8
6663
# @return [Array[String], String] The result of the substitution. Result type is the same as for the target parameter.
6764
# @example Put angle brackets around each octet in the node's IP address:
6865
# ```puppet
@@ -85,10 +82,11 @@ def regsubst_string(target, pattern, replacement, flags = nil, encoding = nil)
8582
when 'E' then re_flags |= Regexp::EXTENDED
8683
when 'I' then re_flags |= Regexp::IGNORECASE
8784
when 'M' then re_flags |= Regexp::MULTILINE
85+
when 'N' then re_flags |= Regexp::NOENCODING
8886
end
8987
end
9088
end
91-
inner_regsubst(target, Regexp.compile(pattern, re_flags, encoding), replacement, operation)
89+
inner_regsubst(target, Regexp.compile(pattern, re_flags), replacement, operation)
9290
end
9391

9492
def regsubst_regexp(target, pattern, replacement, flags = nil)

0 commit comments

Comments
 (0)
Please sign in to comment.