Permalink
Browse files

Remove the :safe flag

  • Loading branch information...
1 parent dde2d17 commit 35c0b757cde2e74f22dda81f60c24417df1374c9 @dtrasbo committed Mar 30, 2012
Showing with 18 additions and 12 deletions.
  1. +6 −6 lib/formatize/helper.rb
  2. +12 −6 test/formatize/helper_test.rb
@@ -25,11 +25,11 @@ module Helper
def textilize(text, *flags)
require 'RedCloth'
- if safe = flags.delete(:safe)
- ActiveSupport::Deprecation.warn('The :safe flag is deprecated. Mark the input HTML safe instead.')
+ if flags.include?(:safe)
+ raise ArgumentError, 'The :safe flag has been removed. Mark the input HTML safe instead or downgrade to Formatize 1.1'
end
- text = sanitize(text) unless text.html_safe? || safe
+ text = sanitize(text) unless text.html_safe?
if text.blank?
""
@@ -73,11 +73,11 @@ def textilize_without_paragraph(text, *flags)
def markdown(text, *flags)
require 'bluecloth'
- if safe = flags.delete(:safe)
- ActiveSupport::Deprecation.warn('The :safe flag is deprecated. Mark the input HTML safe instead.')
+ if flags.include?(:safe)
+ raise ArgumentError, 'The :safe flag has been removed. Mark the input HTML safe instead or downgrade to Formatize 1.1'
end
- text = sanitize(text) unless text.html_safe? || safe
+ text = sanitize(text) unless text.html_safe?
if text.blank?
""
@@ -27,8 +27,10 @@ def test_textilize_should_sanitize_unsafe_input
assert_equal("<p>This is worded <strong>strongly</strong></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>"))
end
- def test_textilize_should_not_sanitize_input_if_safe_flag
- assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>", :safe))
+ def test_textilize_should_raise_error_if_safe_flag
+ assert_raise ArgumentError do
+ textilize("", :safe)
+ end
end
def test_textilize_should_not_sanitize_safe_input
@@ -59,8 +61,10 @@ def test_textilize_without_paragraph_should_sanitize_unsafe_input
assert_equal("This is worded <strong>strongly</strong>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>"))
end
- def test_textilize_without_paragraph_should_not_sanitize_input_if_safe_flag
- assert_equal("This is worded <strong>strongly</strong><script>code!</script>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>", :safe))
+ def test_textilize_without_paragraph_should_raise_error_if_safe_flag
+ assert_raise ArgumentError do
+ textilize_without_paragraph("", :safe)
+ end
end
def test_textilize_without_paragraph_should_not_sanitize_safe_input
@@ -91,8 +95,10 @@ def test_markdown_should_sanitize_unsafe_input
assert_equal("<p>This is worded <strong>strongly</strong></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>"))
end
- def test_markdown_should_not_sanitize_input_if_safe_flag
- assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>", :safe))
+ def test_markdown_should_raise_error_if_safe_flag
+ assert_raise ArgumentError do
+ markdown("", :safe)
+ end
end
def test_markdown_should_not_sanitize_safe_input

0 comments on commit 35c0b75

Please sign in to comment.