Ticket #7707: mime_constants.patch
| File mime_constants.patch, 10.4 kB (added by dkubb, 2 years ago) |
|---|
-
lib/action_controller/request.rb
old new 64 64 @content_type ||= 65 65 begin 66 66 content_type = @env['CONTENT_TYPE'].to_s.downcase 67 67 68 68 if x_post_format = @env['HTTP_X_POST_DATA_FORMAT'] 69 69 case x_post_format.to_s.downcase 70 70 when 'yaml' 71 content_type = 'application/x-yaml'71 content_type = Mime::YAML.to_s 72 72 when 'xml' 73 content_type = 'application/xml'73 content_type = Mime::XML.to_s 74 74 end 75 75 end 76 76 77 77 Mime::Type.lookup(content_type) 78 78 end 79 79 end -
lib/action_controller/test_process.rb
old new 325 325 class TestUploadedFile 326 326 # The filename, *not* including the path, of the "uploaded" file 327 327 attr_reader :original_filename 328 328 329 329 # The content type of the "uploaded" file 330 330 attr_reader :content_type 331 332 def initialize(path, content_type = 'text/plain')331 332 def initialize(path, content_type = Mime::TEXT) 333 333 raise "#{path} file does not exist" unless File.exist?(path) 334 334 @content_type = content_type 335 335 @original_filename = path.sub(/^.*#{File::SEPARATOR}([^#{File::SEPARATOR}]+)$/) { $1 } 336 336 @tempfile = Tempfile.new(@original_filename) 337 337 FileUtils.copy_file(path, @tempfile.path) 338 338 end 339 339 340 340 def path #:nodoc: 341 341 @tempfile.path 342 342 end 343 343 344 344 alias local_path path 345 345 346 346 def method_missing(method_name, *args, &block) #:nodoc: 347 347 @tempfile.send(method_name, *args, &block) 348 348 end 349 349 end 350 350 351 351 module TestProcess 352 352 def self.included(base) 353 353 # execute the request simulating a specific http method and set/volley the response -
lib/action_controller/mime_type.rb
old new 24 24 def initialize(order, name, q=nil) 25 25 @order = order 26 26 @name = name.strip 27 q ||= 0.0 if @name == "*/*" # default "*/*"to end of list27 q ||= 0.0 if @name == Mime::ALL # default wilcard match to end of list 28 28 @q = ((q || 1.0).to_f * 100).to_i 29 29 end 30 30 … … 70 70 71 71 # Take care of the broken text/xml entry by renaming or deleting it 72 72 text_xml = list.index("text/xml") 73 app_xml = list.index( "application/xml")73 app_xml = list.index(Mime::XML.to_s) 74 74 75 75 if text_xml && app_xml 76 76 # set the q value to the max of the two … … 84 84 85 85 # delete text_xml from the list 86 86 list.delete_at(text_xml) 87 87 88 88 elsif text_xml 89 list[text_xml].name = "application/xml"89 list[text_xml].name = Mime::XML.to_s 90 90 end 91 91 92 92 # Look for more specific xml-based types and sort them ahead of app/xml -
lib/action_controller/deprecated_request_methods.rb
old new 6 6 # For backward compatibility, the post format is extracted from the 7 7 # X-Post-Data-Format HTTP header if present. 8 8 def post_format 9 case content_type .to_s10 when 'application/xml'9 case content_type 10 when Mime::XML 11 11 :xml 12 when 'application/x-yaml'12 when Mime::YAML 13 13 :yaml 14 14 else 15 15 :url_encoded -
lib/action_controller/response.rb
old new 20 20 end 21 21 22 22 def charset=(encoding) 23 self.headers["Content-Type"] = "#{content_type || "text/html"}; charset=#{encoding}"23 self.headers["Content-Type"] = "#{content_type || Mime::HTML}; charset=#{encoding}" 24 24 end 25 25 26 26 def charset -
lib/action_view/helpers/url_helper.rb
old new 295 295 for i in 0...tmp.length 296 296 string << sprintf("%%%x",tmp[i]) 297 297 end 298 "<script type=\" text/javascript\">eval(unescape('#{string}'))</script>"298 "<script type=\"#{Mime::JS}\">eval(unescape('#{string}'))</script>" 299 299 elsif encode == "hex" 300 300 email_address_encoded = '' 301 301 email_address_obfuscated.each_byte do |c| -
lib/action_view/helpers/javascript_helper.rb
old new 132 132 # public/javascripts/ directory, and use +javascript_include_tag+ to 133 133 # create remote <script> links. 134 134 def define_javascript_functions 135 javascript = '<script type="text/javascript">'135 javascript = "<script type=\"#{Mime::JS}\">" 136 136 137 137 # load prototype.js and its extensions first 138 138 prototype_libs = Dir.glob(File.join(JAVASCRIPT_PATH, 'prototype*')).sort.reverse … … 166 166 # +html_options+ may be a hash of attributes for the <script> tag. Example: 167 167 # javascript_tag "alert('All is good')", :defer => 'true' # => <script defer="true" type="text/javascript">alert('All is good')</script> 168 168 def javascript_tag(content, html_options = {}) 169 content_tag("script", javascript_cdata_section(content), html_options.merge(:type => "text/javascript"))169 content_tag("script", javascript_cdata_section(content), html_options.merge(:type => Mime::JS)) 170 170 end 171 171 172 172 def javascript_cdata_section(content) #:nodoc: -
lib/action_view/helpers/java_script_macros_helper.rb
old new 198 198 content_tag("div", "", :id => "#{object}_#{method}_auto_complete", :class => "auto_complete") + 199 199 auto_complete_field("#{object}_#{method}", { :url => { :action => "auto_complete_for_#{object}_#{method}" } }.update(completion_options)) 200 200 end 201 201 202 202 private 203 203 def auto_complete_stylesheet 204 content_tag('style', <<-EOT, :type => 'text/css')204 content_tag('style', <<-EOT, :type => Mime::CSS) 205 205 div.auto_complete { 206 206 width: 350px; 207 207 background: #fff; … … 217 217 margin:0; 218 218 padding:3px; 219 219 } 220 div.auto_complete ul li.selected { 221 background-color: #ffb; 220 div.auto_complete ul li.selected { 221 background-color: #ffb; 222 222 } 223 div.auto_complete ul strong.highlight { 223 div.auto_complete ul strong.highlight { 224 224 color: #800; 225 225 margin:0; 226 226 padding:0; 227 227 } 228 228 EOT 229 229 end 230 230 231 231 end 232 232 end 233 233 end -
lib/action_view/helpers/asset_tag_helper.rb
old new 149 149 if !File.exists?(joined_javascript_path) 150 150 File.open(joined_javascript_path, "w+") do |cache| 151 151 javascript_paths = expand_javascript_sources(sources).collect do |source| 152 compute_public_path(source, 'javascripts', 'js', false) 152 compute_public_path(source, 'javascripts', 'js', false) 153 153 end 154 154 155 155 cache.write(join_asset_file_contents(javascript_paths)) 156 156 end 157 157 end 158 158 159 content_tag("script", "", { 160 "type" => "text/javascript", "src" => javascript_path(joined_javascript_name)159 content_tag("script", "", { 160 "type" => Mime::JS, "src" => javascript_path(joined_javascript_name) 161 161 }.merge(options)) 162 162 else 163 163 expand_javascript_sources(sources).collect do |source| 164 content_tag("script", "", { "type" => "text/javascript", "src" => javascript_path(source) }.merge(options))164 content_tag("script", "", { "type" => Mime::JS, "src" => javascript_path(source) }.merge(options)) 165 165 end.join("\n") 166 166 end 167 167 end … … 252 252 end 253 253 254 254 tag("link", { 255 "rel" => "Stylesheet", "type" => "text/css", "media" => "screen",255 "rel" => "Stylesheet", "type" => Mime::CSS, "media" => "screen", 256 256 "href" => stylesheet_path(joined_stylesheet_name) 257 257 }.merge(options)) 258 258 else 259 259 options.delete("cache") 260 260 261 261 expand_stylesheet_sources(sources).collect do |source| 262 tag("link", { 263 "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => stylesheet_path(source)262 tag("link", { 263 "rel" => "Stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => stylesheet_path(source) 264 264 }.merge(options)) 265 265 end.join("\n") 266 266 end -
lib/action_view/base.rb
old new 470 470 if template_requires_setup?(extension) 471 471 body = case extension.to_sym 472 472 when :rxml, :builder 473 "controller.response.content_type ||= 'application/xml'\n" +473 "controller.response.content_type ||= Mime::XML\n" + 474 474 "xml = Builder::XmlMarkup.new(:indent => 2)\n" + 475 475 template 476 476 when :rjs 477 "controller.response.content_type ||= 'text/javascript'\n" +477 "controller.response.content_type ||= Mime::JS\n" + 478 478 "update_page do |page|\n#{template}\nend" 479 479 end 480 480 else