Merge pull request #45029 from jonathanhefner/fix-extract_dimensions-regexp

Escape literal dot in regular expression
This commit is contained in:
Jean Boussier 2022-05-09 09:55:00 +02:00 committed by GitHub
commit dd0b302378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -527,9 +527,9 @@ module ActionView
def extract_dimensions(size)
size = size.to_s
if /\A(\d+|\d+.\d+)x(\d+|\d+.\d+)\z/.match?(size)
if /\A\d+(?:\.\d+)?x\d+(?:\.\d+)?\z/.match?(size)
size.split("x")
elsif /\A(\d+|\d+.\d+)\z/.match?(size)
elsif /\A\d+(?:\.\d+)?\z/.match?(size)
[size, size]
end
end

View File

@ -230,6 +230,8 @@ class AssetTagHelperTest < ActionView::TestCase
%(image_tag("platinum.png", :size => "4.9x20")) => %(<img height="20" src="/images/platinum.png" width="4.9" />),
%(image_tag("platinum.png", "size" => "4.9x20")) => %(<img height="20" src="/images/platinum.png" width="4.9" />),
%(image_tag("error.png", "size" => "45 x 70")) => %(<img src="/images/error.png" />),
%(image_tag("error.png", "size" => "1,024x768")) => %(<img src="/images/error.png" />),
%(image_tag("error.png", "size" => "768x1,024")) => %(<img src="/images/error.png" />),
%(image_tag("error.png", "size" => "x")) => %(<img src="/images/error.png" />),
%(image_tag("google.com.png")) => %(<img src="/images/google.com.png" />),
%(image_tag("slash..png")) => %(<img src="/images/slash..png" />),
@ -312,6 +314,8 @@ class AssetTagHelperTest < ActionView::TestCase
%(video_tag("error.avi", "size" => "100")) => %(<video height="100" src="/videos/error.avi" width="100"></video>),
%(video_tag("error.avi", "size" => 100)) => %(<video height="100" src="/videos/error.avi" width="100"></video>),
%(video_tag("error.avi", "size" => "100 x 100")) => %(<video src="/videos/error.avi"></video>),
%(video_tag("error.avi", "size" => "1,024x768")) => %(<video src="/videos/error.avi"></video>),
%(video_tag("error.avi", "size" => "768x1,024")) => %(<video src="/videos/error.avi"></video>),
%(video_tag("error.avi", "size" => "x")) => %(<video src="/videos/error.avi"></video>),
%(video_tag("http://media.rubyonrails.org/video/rails_blog_2.mov")) => %(<video src="http://media.rubyonrails.org/video/rails_blog_2.mov"></video>),
%(video_tag("//media.rubyonrails.org/video/rails_blog_2.mov")) => %(<video src="//media.rubyonrails.org/video/rails_blog_2.mov"></video>),