/usr/lib/ruby/vendor_ruby/rack/mount/strexp/parser.y is in ruby-rack-mount 0.8.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | class Rack::Mount::StrexpParser
rule
target: expr { result = anchor ? "\\A#{val.join}\\Z" : "\\A#{val.join}" }
expr: expr token { result = val.join }
| token
token: PARAM {
name = val[0].to_sym
requirement = requirements[name]
result = REGEXP_NAMED_CAPTURE % [name, requirement]
}
| GLOB {
name = val[0].to_sym
requirement = requirements.key?(name) ? requirements[name] : '.+'
result = REGEXP_NAMED_CAPTURE % [name, requirement]
}
| LPAREN expr RPAREN { result = "(?:#{val[1]})?" }
| CHAR { result = Regexp.escape(val[0]) }
end
---- header ----
require 'rack/mount/utils'
require 'rack/mount/strexp/tokenizer'
---- inner
if Regin.regexp_supports_named_captures?
REGEXP_NAMED_CAPTURE = '(?<%s>%s)'.freeze
else
REGEXP_NAMED_CAPTURE = '(?:<%s>%s)'.freeze
end
attr_accessor :anchor, :requirements
|