Skip to content

Multiple dollar signs or non-price dollar signs pass through in to_url #197

Description

@abachman

We're using stringex 2.7.1 in a Rails project and noticed that dollar signs come through with the acts_as_url plugin and .to_url string method if they're multiples or not preceding numbers.

Two examples, one with $ signs and one with a list of reserved URI characters.

First, variations on the $ sign:

"1$ item".to_url    # => "1$-item"
"$1 item".to_url    # => "1-dollars-item"
"$1$ item".to_url   # => "$1$-item"
"$$1 item".to_url   # => "$$1-item"
"$1 $item".to_url   # => "1-dollars-$item"
"$ 1 item".to_url   # => "dollars-1-item"
"1 $ item".to_url   # => "1-dollars-item"
"1 $$ item".to_url  # => "1-$$-item"
"1 $$$ item".to_url # => "1-$$$-item"

Second, with a list of reserved characters taken from the URI RFC:

irb> %w(: / ?  #  [  ]  @ !  $  &  '  (  )  *  +  ,  ;  =).each {|c| puts "a #{c}#{c} b".to_url }
a-b
a-slash-slash-b
a-b
a-number-number-b
a-b
a-b
a-at-at-b
a-b
a-$$-b
a-and-and-b
a-b
a-b
a-b
a-star-star-b
a-plus-plus-b
a-b
a-b
a-equals-equals-b

Not sure if it's intentional but it breaks some of our routes that have been constraining the parameter provided by acts_as_url with /[0-9A-Za-z\-\.]+/, which worked fine up until this point.

If it's not a bug, can you recommend a better constraint or the set of characters that are allowed through .to_url?

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions