aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller/cgi_ext/cgi_methods.rb23
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb2
2 files changed, 23 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
index 3a14311acf..ac2dae9989 100755
--- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
+++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
@@ -88,9 +88,30 @@ class CGIMethods #:nodoc:
# test most frequent case first
if value.is_a?(String)
value
- elsif value.respond_to?(:content_type) && !value.content_type.empty?
+ elsif value.respond_to?(:content_type)
# Uploaded file
+ unless value.respond_to?(:full_original_filename)
+ class << value
+ alias_method :full_original_filename, :original_filename
+
+ # Take the basename of the upload's original filename.
+ # This handles the full Windows paths given by Internet Explorer
+ # (and perhaps other broken user agents) without affecting
+ # those which give the lone filename.
+ # The Windows regexp is adapted from Perl's File::Basename.
+ def original_filename
+ if md = /^(?:.*[:\\\/])?(.*)/m.match(full_original_filename)
+ md.captures.first
+ else
+ File.basename full_original_filename
+ end
+ end
+ end
+ end
+
+ # Return the same value after overriding original_filename.
value
+
elsif value.respond_to?(:read)
# Value as part of a multipart request
value.read
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 8be3d3589c..cafed43aed 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -301,7 +301,7 @@ module ActionView
(?:\#\w*)? # trailing anchor
)
([[:punct:]]|\s|<|$) # trailing text
- /x
+ /x unless const_defined?(:AUTO_LINK_RE)
# Turns all urls into clickable links.
def auto_link_urls(text, href_options = {})