mirror of
https://github.com/github/rails.git
synced 2026-01-13 00:28:26 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81d67c66b0 |
@@ -1 +1 @@
|
|||||||
2.3.14.github41
|
2.3.14.github38
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ module ActionController #:nodoc:
|
|||||||
log_message << " [#{complete_request_uri rescue "unknown"}]"
|
log_message << " [#{complete_request_uri rescue "unknown"}]"
|
||||||
|
|
||||||
logger.info(log_message)
|
logger.info(log_message)
|
||||||
|
response.headers["X-Runtime"] = "%.0f" % ms
|
||||||
else
|
else
|
||||||
perform_action_without_benchmark
|
perform_action_without_benchmark
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module ActionController
|
|||||||
# Note that changing digest or secret invalidates all existing sessions!
|
# Note that changing digest or secret invalidates all existing sessions!
|
||||||
class CookieStore
|
class CookieStore
|
||||||
include AbstractStore::SessionUtils
|
include AbstractStore::SessionUtils
|
||||||
|
|
||||||
# Cookies can typically store 4096 bytes.
|
# Cookies can typically store 4096 bytes.
|
||||||
MAX = 4096
|
MAX = 4096
|
||||||
SECRET_MIN_LENGTH = 30 # characters
|
SECRET_MIN_LENGTH = 30 # characters
|
||||||
@@ -95,21 +95,14 @@ module ActionController
|
|||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
prepare!(env)
|
prepare!(env)
|
||||||
|
|
||||||
status, headers, body = @app.call(env)
|
status, headers, body = @app.call(env)
|
||||||
|
|
||||||
session_data = env[ENV_SESSION_KEY]
|
session_data = env[ENV_SESSION_KEY]
|
||||||
options = env[ENV_SESSION_OPTIONS_KEY]
|
options = env[ENV_SESSION_OPTIONS_KEY]
|
||||||
request = ActionController::Request.new(env)
|
request = ActionController::Request.new(env)
|
||||||
|
|
||||||
if !(options[:secure] && !request.ssl?) && (!session_data.is_a?(AbstractStore::SessionHash) || session_data.loaded? || options[:expire_after])
|
if !(options[:secure] && !request.ssl?) && (!session_data.is_a?(AbstractStore::SessionHash) || session_data.loaded? || options[:expire_after])
|
||||||
|
|
||||||
# Backport standard Rack::Session::Cookie behavior
|
|
||||||
# Skip writing session if env['rack.session.options'][:skip] is set
|
|
||||||
if options[:skip]
|
|
||||||
return [status, headers, body]
|
|
||||||
end
|
|
||||||
|
|
||||||
session_data.send(:load!) if session_data.is_a?(AbstractStore::SessionHash) && !session_data.loaded?
|
session_data.send(:load!) if session_data.is_a?(AbstractStore::SessionHash) && !session_data.loaded?
|
||||||
|
|
||||||
persistent_session_id!(session_data)
|
persistent_session_id!(session_data)
|
||||||
@@ -129,7 +122,7 @@ module ActionController
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def prepare!(env)
|
def prepare!(env)
|
||||||
env[ENV_SESSION_KEY] = AbstractStore::SessionHash.new(self, env)
|
env[ENV_SESSION_KEY] = AbstractStore::SessionHash.new(self, env)
|
||||||
env[ENV_SESSION_OPTIONS_KEY] = AbstractStore::OptionsHash.new(self, env, @default_options)
|
env[ENV_SESSION_OPTIONS_KEY] = AbstractStore::OptionsHash.new(self, env, @default_options)
|
||||||
@@ -140,7 +133,7 @@ module ActionController
|
|||||||
data = persistent_session_id!(data)
|
data = persistent_session_id!(data)
|
||||||
[data[:session_id], data]
|
[data[:session_id], data]
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_session_id(env)
|
def extract_session_id(env)
|
||||||
if data = unpacked_cookie_data(env)
|
if data = unpacked_cookie_data(env)
|
||||||
persistent_session_id!(data) unless data.empty?
|
persistent_session_id!(data) unless data.empty?
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ module ActionView
|
|||||||
def number_to_currency(number, options = {})
|
def number_to_currency(number, options = {})
|
||||||
options.symbolize_keys!
|
options.symbolize_keys!
|
||||||
|
|
||||||
options[:format] = ERB::Util.html_escape(options[:format]) if options[:format]
|
|
||||||
|
|
||||||
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
|
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
|
||||||
currency = I18n.translate(:'number.currency.format', :locale => options[:locale], :raise => true) rescue {}
|
currency = I18n.translate(:'number.currency.format', :locale => options[:locale], :raise => true) rescue {}
|
||||||
defaults = defaults.merge(currency)
|
defaults = defaults.merge(currency)
|
||||||
|
|||||||
@@ -3,12 +3,6 @@ require 'abstract_unit'
|
|||||||
class NumberHelperTest < ActionView::TestCase
|
class NumberHelperTest < ActionView::TestCase
|
||||||
tests ActionView::Helpers::NumberHelper
|
tests ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
def test_number_helpers_escape_delimiter_and_separator
|
|
||||||
assert_equal "$1<script></script>01", number_to_currency(1.01, :separator => "<script></script>")
|
|
||||||
assert_equal "$1<script></script>000.00", number_to_currency(1000, :delimiter => "<script></script>")
|
|
||||||
assert_equal "<script>1,000.00$</script>", number_to_currency(1000, :format => "<script>%n%u</script>")
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_number_to_phone
|
def test_number_to_phone
|
||||||
assert_equal("555-1234", number_to_phone(5551234))
|
assert_equal("555-1234", number_to_phone(5551234))
|
||||||
assert_equal("800-555-1212", number_to_phone(8005551212))
|
assert_equal("800-555-1212", number_to_phone(8005551212))
|
||||||
|
|||||||
@@ -195,9 +195,7 @@ module ActiveRecord
|
|||||||
def log_info(sql, name, ms)
|
def log_info(sql, name, ms)
|
||||||
if @logger && @logger.debug?
|
if @logger && @logger.debug?
|
||||||
name = '%s (%.1fms)' % [name || 'SQL', ms]
|
name = '%s (%.1fms)' % [name || 'SQL', ms]
|
||||||
if sql.respond_to?(:force_encoding)
|
sql.force_encoding 'binary' if sql.respond_to?(:force_encoding)
|
||||||
sql = sql.dup.force_encoding 'binary'
|
|
||||||
end
|
|
||||||
@logger.debug(format_log_entry(name, sql.squeeze(' ')))
|
@logger.debug(format_log_entry(name, sql.squeeze(' ')))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
require 'active_support/core_ext/kernel/daemonizing'
|
require 'active_support/core_ext/kernel/daemonizing'
|
||||||
require 'active_support/core_ext/kernel/reporting'
|
require 'active_support/core_ext/kernel/reporting'
|
||||||
|
require 'active_support/core_ext/kernel/agnostics'
|
||||||
require 'active_support/core_ext/kernel/requires'
|
require 'active_support/core_ext/kernel/requires'
|
||||||
require 'active_support/core_ext/kernel/debugger'
|
require 'active_support/core_ext/kernel/debugger'
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class Object
|
||||||
|
# Makes backticks behave (somewhat more) similarly on all platforms.
|
||||||
|
# On win32 `nonexistent_command` raises Errno::ENOENT; on Unix, the
|
||||||
|
# spawned shell prints a message to stderr and sets $?. We emulate
|
||||||
|
# Unix on the former but not the latter.
|
||||||
|
def `(command) #:nodoc:
|
||||||
|
super
|
||||||
|
rescue Errno::ENOENT => e
|
||||||
|
STDERR.puts "#$0: #{e}"
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user