Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 19 additions and 13 deletions.
  1. +1 −1  LICENSE
  2. +6 −6 lib/formatize/helper.rb
  3. +12 −6 test/formatize/helper_test.rb
View
2  LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2010 David Trasbo
+Copyright (c) 2012 David Trasbo
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
View
12 lib/formatize/helper.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?
""
View
18 test/formatize/helper_test.rb
@@ -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

No commit comments for this range

Something went wrong with that request. Please try again.