From 2dd0ec48a5068a095e362fad2a77d63b86fdfd95 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 23 Nov 2008 19:12:00 -0800 Subject: Autoload HTML::Document and sanitizers --- .../lib/action_controller/assertions/response_assertions.rb | 3 --- .../lib/action_controller/assertions/selector_assertions.rb | 3 +-- actionpack/lib/action_controller/assertions/tag_assertions.rb | 5 +---- actionpack/lib/action_controller/vendor/html-scanner.rb | 9 +++++++++ actionpack/lib/action_view/helpers/sanitize_helper.rb | 11 +---------- actionpack/lib/action_view/helpers/text_helper.rb | 10 ---------- 6 files changed, 12 insertions(+), 29 deletions(-) create mode 100644 actionpack/lib/action_controller/vendor/html-scanner.rb (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb index e2e8bbdc71..7ab24389b8 100644 --- a/actionpack/lib/action_controller/assertions/response_assertions.rb +++ b/actionpack/lib/action_controller/assertions/response_assertions.rb @@ -1,6 +1,3 @@ -require 'rexml/document' -require 'html/document' - module ActionController module Assertions # A small suite of assertions that test responses from Rails applications. diff --git a/actionpack/lib/action_controller/assertions/selector_assertions.rb b/actionpack/lib/action_controller/assertions/selector_assertions.rb index bcbb570e4b..40ac572fdb 100644 --- a/actionpack/lib/action_controller/assertions/selector_assertions.rb +++ b/actionpack/lib/action_controller/assertions/selector_assertions.rb @@ -3,8 +3,7 @@ # Under MIT and/or CC By license. #++ -require 'rexml/document' -require 'html/document' +require 'action_controller/vendor/html-scanner' module ActionController module Assertions diff --git a/actionpack/lib/action_controller/assertions/tag_assertions.rb b/actionpack/lib/action_controller/assertions/tag_assertions.rb index 90ba3668fb..80249e0e83 100644 --- a/actionpack/lib/action_controller/assertions/tag_assertions.rb +++ b/actionpack/lib/action_controller/assertions/tag_assertions.rb @@ -1,6 +1,3 @@ -require 'rexml/document' -require 'html/document' - module ActionController module Assertions # Pair of assertions to testing elements in the HTML output of the response. @@ -127,4 +124,4 @@ module ActionController end end end -end \ No newline at end of file +end diff --git a/actionpack/lib/action_controller/vendor/html-scanner.rb b/actionpack/lib/action_controller/vendor/html-scanner.rb new file mode 100644 index 0000000000..5c6db99858 --- /dev/null +++ b/actionpack/lib/action_controller/vendor/html-scanner.rb @@ -0,0 +1,9 @@ +$LOAD_PATH << "#{File.dirname(__FILE__)}/html-scanner" + +module HTML + autoload :Document, 'html/document' + autoload :Sanitizer, 'html/sanitizer' + autoload :FullSanitizer, 'html/sanitizer' + autoload :LinkSanitizer, 'html/sanitizer' + autoload :WhiteListSanitizer, 'html/sanitizer' +end diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb index 435ba936e1..200c1d6085 100644 --- a/actionpack/lib/action_view/helpers/sanitize_helper.rb +++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb @@ -1,14 +1,5 @@ require 'action_view/helpers/tag_helper' - -begin - require 'html/document' -rescue LoadError - html_scanner_path = "#{File.dirname(__FILE__)}/../../action_controller/vendor/html-scanner" - if File.directory?(html_scanner_path) - $:.unshift html_scanner_path - require 'html/document' - end -end +require 'action_controller/vendor/html-scanner' module ActionView module Helpers #:nodoc: diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 510c1a6a76..506138a735 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -1,15 +1,5 @@ require 'action_view/helpers/tag_helper' -begin - require 'html/document' -rescue LoadError - html_scanner_path = "#{File.dirname(__FILE__)}/../../action_controller/vendor/html-scanner" - if File.directory?(html_scanner_path) - $:.unshift html_scanner_path - require 'html/document' - end -end - module ActionView module Helpers #:nodoc: # The TextHelper module provides a set of methods for filtering, formatting -- cgit v1.2.3