Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

rafactored the regex related code in the mapper class #1523

Merged
merged 2 commits into from

3 participants

@raghunadhd

No description provided.

@fxn

Since these %r literals use no slashes as delimiters, some of the backslashes in the original code are no longer needed (and better removed).

@raghunadhd

Ok. I will update the corresponding changes in the next commit. Thanks.

/cc @fxn.

@raghunadhd

Commits Updated.

/cc @fxn

@fxn
Owner

Thanks!

@fxn fxn merged commit 90c4885 into from
@jake3030 jake3030 referenced this pull request from a commit in jake3030/rails
@libc libc Ensure auto_link doesnt linkify URLs in the middle of a tag [#1523 st…
…ate:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
bdfa733
@jake3030 jake3030 referenced this pull request from a commit in jake3030/rails
@mislav mislav avoid auto_linking already linked emails; more robust detection of li…
…nked URLs

References #1523  [#1862 state:resolved]  [#3591 state:resolved]

Add test that shows how link text can contain HTML if needed:
the trick is using block form in combination with `raw`.
Let link text be automatically HTML-escaped

[#2017 state:resolved]
8f0b213
@jake3030 jake3030 referenced this pull request from a commit in jake3030/rails
@mislav mislav avoid auto_linking already linked emails; more robust detection of li…
…nked URLs

References #1523  [#1862 state:resolved]  [#3591 state:resolved]

Add test that shows how link text can contain HTML if needed:
the trick is using block form in combination with `raw`.
Let link text be automatically HTML-escaped

[#2017 state:resolved]
533b131
@svenfuchs svenfuchs referenced this pull request from a commit in svenfuchs/rails
@mislav mislav avoid auto_linking already linked emails; more robust detection of li…
…nked URLs

References #1523  [#1862 state:resolved]  [#3591 state:resolved]

Add test that shows how link text can contain HTML if needed:
the trick is using block form in combination with `raw`.
Let link text be automatically HTML-escaped

[#2017 state:resolved]
17b4fd2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 4 deletions.
  1. +7 −4 actionpack/lib/action_dispatch/routing/mapper.rb
View
11 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -49,6 +49,9 @@ def constraint_args(constraint, request)
class Mapping #:nodoc:
IGNORE_OPTIONS = [:to, :as, :via, :on, :constraints, :defaults, :only, :except, :anchor, :shallow, :shallow_path, :shallow_prefix]
+ ANCHOR_CHARACTERS_REGEX = %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
+ SHORTHAND_REGEX = %r{^/[\w/]+$}
+ WILDCARD_PATH = %r{\*([^/]+)$}
def initialize(set, scope, path, options)
@set, @scope = set, scope
@@ -77,18 +80,18 @@ def normalize_options!
# segment_keys.include?(k.to_s) || k == :controller
next unless Regexp === requirement && !constraints[name]
- if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
+ if requirement.source =~ ANCHOR_CHARACTERS_REGEX
raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
end
if requirement.multiline?
raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
end
end
- end
+ end
# match "account/overview"
def using_match_shorthand?(path, options)
- path && options.except(:via, :anchor, :to, :as).empty? && path =~ %r{^/[\w\/]+$}
+ path && options.except(:via, :anchor, :to, :as).empty? && path =~ SHORTHAND_REGEX
end
def normalize_path(path)
@@ -107,7 +110,7 @@ def normalize_path(path)
# Add a constraint for wildcard route to make it non-greedy and match the
# optional format part of the route by default
- if path.match(/\*([^\/]+)$/) && @options[:format] != false
+ if path.match(WILDCARD_PATH) && @options[:format] != false
@options.reverse_merge!(:"#{$1}" => /.+?/)
end
Something went wrong with that request. Please try again.