Class: Ruby::Rego::Builtins::Regex::GlobIntersection::RuneBudget

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/rego/builtins/regex/glob_intersection/tokenizer.rb

Overview

Bounds cumulative character-class range expansion across one glob so a range-packed pattern cannot do unbounded work during tokenization.

Instance Method Summary collapse

Constructor Details

#initialize(limit) ⇒ RuneBudget

Returns a new instance of RuneBudget.



17
18
19
# File 'lib/ruby/rego/builtins/regex/glob_intersection/tokenizer.rb', line 17

def initialize(limit)
  @remaining = limit
end

Instance Method Details

#charge(count) ⇒ Object

Raises:



21
22
23
24
# File 'lib/ruby/rego/builtins/regex/glob_intersection/tokenizer.rb', line 21

def charge(count)
  @remaining -= count
  raise GlobError, "character classes expand too many characters" if @remaining.negative?
end