Skip to content

Commit

Permalink
Validate template extensions [#1187 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Dec 3, 2008
1 parent 99f2cb4 commit 2fc6c7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 6 additions & 8 deletions actionpack/lib/action_view/template.rb
Expand Up @@ -115,16 +115,14 @@ def find_full_path(path, load_paths)
# [base_path, name, format, extension]
def split(file)
if m = file.match(/^(.*\/)?([^\.]+)\.?(\w+)?\.?(\w+)?\.?(\w+)?$/)
if m[5] # Multipart formats
if valid_extension?(m[5]) # Multipart formats
[m[1], m[2], "#{m[3]}.#{m[4]}", m[5]]
elsif m[4] # Single format
elsif valid_extension?(m[4]) # Single format
[m[1], m[2], m[3], m[4]]
else
if valid_extension?(m[3]) # No format
[m[1], m[2], nil, m[3]]
else # No extension
[m[1], m[2], m[3], nil]
end
elsif valid_extension?(m[3]) # No format
[m[1], m[2], nil, m[3]]
else # No extension
[m[1], m[2], m[3], nil]
end
end
end
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/fixtures/test/dont_pick_me
@@ -0,0 +1 @@
non-template file

1 comment on commit 2fc6c7d

@josh
Copy link
Contributor Author

@josh josh commented on 2fc6c7d Dec 3, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run your AM tests!

Please sign in to comment.