regexp_parser 2.6.1 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a468f97c0fecc8b90781d4d6775f82423fd5e7f15561a419be849b1d24fe05d9
4
- data.tar.gz: c5c78beabe6ebe360b4f7cdede3c62149f4eba3c1556fd55cf02e3300cdb38b7
3
+ metadata.gz: 66568005494b517613155277c6be4731eb8a26bb9b48a692a9430507286ce583
4
+ data.tar.gz: d1fc6c6f1a0c7f939c51703ac844c2dbb134f96e0e55780646cb7e3e87d7a652
5
5
  SHA512:
6
- metadata.gz: a3b86a8f66154804b49d227ad4653cb969f1c337d4dc90de09e116e39cd87f608a12d29cc0422e4b1b4201234bc2b5b6467b065d94c274674fb1c555a04518d8
7
- data.tar.gz: fb26d224504f71645645013ee3dd5a07066b0323f9c97f8c0a716e75ea0d4fdffbf41c0526eafdf19c6d7fe1772d6616aec71541dc46d51123640cfc76b703f6
6
+ metadata.gz: b955b2215b71c94497e52841142fab8c2b9930d0d6cea6ea2b3eeb8ed9fe84575e2f34aae3a6051af2b56429f98cf070b9151805f2cb93ddb511ec1e0e50dd7c
7
+ data.tar.gz: 3a4f083942b66ddb4b67ab33f14bb1c0b724a60c2b30605059d32ce3648e9cb46e31e797b7a526a2028c1e018d73365f5ef955256de4e63397d6ea105714ff12
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.6.2] - 2023-01-19 - [Janosch Müller](mailto:janosch84@gmail.com)
11
+
12
+ ### Fixed
13
+
14
+ - fixed `SystemStackError` when cloning recursive subexpression calls
15
+ * e.g. `Regexp::Parser.parse(/a|b\g<0>/).dup`
16
+
10
17
  ## [2.6.1] - 2022-11-16 - [Janosch Müller](mailto:janosch84@gmail.com)
11
18
 
12
19
  ### Fixed
@@ -5,7 +5,19 @@ module Regexp::Expression
5
5
  attr_accessor :referenced_expression
6
6
 
7
7
  def initialize_copy(orig)
8
- self.referenced_expression = orig.referenced_expression.dup
8
+ exp_id = [self.class, self.starts_at]
9
+
10
+ # prevent infinite recursion for recursive subexp calls
11
+ copied = @@copied ||= {}
12
+ self.referenced_expression =
13
+ if copied[exp_id]
14
+ orig.referenced_expression
15
+ else
16
+ copied[exp_id] = true
17
+ orig.referenced_expression.dup
18
+ end
19
+ copied.clear
20
+
9
21
  super
10
22
  end
11
23
  end
@@ -63,16 +63,20 @@ class Regexp::MatchLength
63
63
  end
64
64
 
65
65
  def to_re
66
- "(?:#{reify.call}){#{min_rep},#{max_rep unless max_rep == Float::INFINITY}}"
66
+ /(?:#{reify.call}){#{min_rep},#{max_rep unless max_rep == Float::INFINITY}}/
67
67
  end
68
68
 
69
69
  private
70
70
 
71
71
  attr_accessor :base_min, :base_max, :min_rep, :max_rep, :exp_class, :reify
72
72
 
73
- def test_regexp
74
- @test_regexp ||= Regexp.new("^#{to_re}$").tap do |regexp|
75
- regexp.respond_to?(:match?) || def regexp.match?(str); !!match(str) end
73
+ if Regexp.method_defined?(:match?) # ruby >= 2.4
74
+ def test_regexp
75
+ @test_regexp ||= /^#{to_re}$/
76
+ end
77
+ else
78
+ def test_regexp
79
+ @test_regexp ||= /^#{to_re}$/.tap { |r| def r.match?(s); !!match(s) end }
76
80
  end
77
81
  end
78
82
  end
@@ -1,5 +1,5 @@
1
1
  class Regexp
2
2
  class Parser
3
- VERSION = '2.6.1'
3
+ VERSION = '2.6.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regexp_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ammar Ali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-16 00:00:00.000000000 Z
11
+ date: 2023-01-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library for tokenizing, lexing, and parsing Ruby regular expressions.
14
14
  email: