Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of updates that should be merged into master... #135

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5de4a16
Added autotest for quicker testing. Running 'rake test' over and over…
Apr 23, 2014
da13ebe
Ensure that image tags inside markdown code don't get transformed int…
Apr 23, 2014
b46ca4b
Some URLs can cause "bad URI error" when using the URI lib.
Apr 23, 2014
f59c376
Merge branch 'bug/soundcloud-filter-bad-uri'
Apr 23, 2014
56f06c7
Wrap all video filters with standard DIVs for CSS control.
Apr 24, 2014
212dae1
Merge branch 'feature/wrap-video-filters-with-div'
Apr 24, 2014
422eefc
Tweak autotest file
Apr 24, 2014
a164cd6
Prevent links inside already pasted HTML from being transformed again
Apr 24, 2014
f3b1f8c
Merge branch 'bug/dailymotion-prevent-transform-video-embed'
Apr 24, 2014
a156114
Added extra tests to other video filters to prevent HTML embed regres…
Apr 26, 2014
1d675d2
Merge branch 'bug/dailymotion-prevent-transform-video-embed'
Apr 26, 2014
e056442
Fixed bug where instagram filter was appending slash
Apr 26, 2014
9b1a7e4
Merge branch 'bug/fix-instagram-slash-bug'
Apr 26, 2014
6206bcb
Added autotest for quicker testing. Running 'rake test' over and over…
Apr 23, 2014
2860447
Ensure that image tags inside markdown code don't get transformed int…
Apr 23, 2014
a3886c0
Some URLs can cause "bad URI error" when using the URI lib.
Apr 23, 2014
f0fc70a
Wrap all video filters with standard DIVs for CSS control.
Apr 24, 2014
f9f18bf
Tweak autotest file
Apr 24, 2014
3e715ef
Prevent links inside already pasted HTML from being transformed again
Apr 24, 2014
5a43a78
Added extra tests to other video filters to prevent HTML embed regres…
Apr 26, 2014
c27fd36
Fixed bug where instagram filter was appending slash
Apr 26, 2014
026d9f6
Merge remote-tracking branch 'origin/master'
Nov 11, 2014
b1afe37
Updated autotest / minitest / rails for better test output
Nov 11, 2014
789235a
Added Flickr test to prevent JSON errors - but original code doesn't …
Feb 1, 2015
f763415
Forgot to checkin flickr test
Feb 1, 2015
32ecf3d
More robust testing to ensure Youtube doesn't transform inside links
Mar 11, 2015
0d9a44a
Fix soundcloud transform when inside anchor
Aug 20, 2015
a6c4ad4
Fix gem dependencies with rails sanitizer
Aug 20, 2015
5d9a6d5
Fix bum test, ensure IG links don't transform inside HTML
Nov 4, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions .autotest
@@ -0,0 +1,30 @@
require 'autotest/growl'
require 'autotest/fsevent'

Autotest.add_hook :initialize do |at|
unless ARGV.empty?
at.find_directories = ARGV
else
# Clear all mappings
#at.clear_mappings

# Ignore these files
%w(
.hg .git .svn stories tmtags
Gemfile Rakefile Capfile README
.html app/assets config .keep
spec/spec.opts spec/rcov.opts vendor/gems vendor/ruby
autotest svn-commit .DS_Store
).each { |exception|at.add_exception(exception) }

at.add_mapping(%r{^lib/auto_html/filters/.*\.rb$}) do |f, _|
at.files_matching %r{^test/unit/filters/.*_test\.rb$}
end

# Now add support for the test files themselves
at.add_mapping(%r%^test/(.*)/(.*)\_test.rb$%) do |file, m|
at.files_matching %r%#{file}%
end

end
end
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,5 @@ test.sqlite3
TODO
Gemfile.lock
*.gem
.bundle
vendor
23 changes: 11 additions & 12 deletions Gemfile
Expand Up @@ -2,17 +2,16 @@ source "http://rubygems.org"

gemspec

rails_version = ENV["RAILS_VERSION"] || "default"

rails = case rails_version
when "master"
{github: "rails/rails"}
when "default"
"~> 3.2.0"
else
"~> #{rails_version}"
end

gem "rails", rails
gem "rails", '~> 4.1'
gem 'sqlite3', '~> 1.3.3'
gem 'fakeweb'

# For testing
gem 'minitest'
#gem 'minitest-autotest'
gem 'minitest-reporters'
gem 'minitest-focus'

gem 'autotest'
gem 'autotest-growl'
gem 'autotest-fsevent'
1 change: 1 addition & 0 deletions auto_html.gemspec
Expand Up @@ -11,6 +11,7 @@ Gem::Specification.new do |gem|

gem.add_dependency('rinku', '~> 1.7')
gem.add_dependency('redcarpet', '~> 3.1')
gem.add_dependency('rails-html-sanitizer', '~> 1.0.2')

# ensure the gem is built out of versioned files
gem.files = Dir['Rakefile', '{bin,lib,man,test,spec}/**/*',
Expand Down
4 changes: 2 additions & 2 deletions lib/auto_html/filters/dailymotion.rb
@@ -1,6 +1,6 @@
AutoHtml.add_filter(:dailymotion).with(:width => 480, :height => 360) do |text, options|
text.gsub(/http:\/\/www\.dailymotion\.com.*\/video\/(.+)_*/) do
text.gsub(/(?<!=")https?:\/\/www\.dailymotion\.com.*\/video\/(.+)_*/) do
video_id = $1
%{<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/#{video_id}&related=0" width="#{options[:width]}" height="#{options[:height]}"><param name="movie" value="http://www.dailymotion.com/swf/#{video_id}&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/#{video_id}?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/#{video_id}" width="#{options[:width]}" height="#{options[:height]}"/></a></object>}
%{<div class="video-container dailymotion"><object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/#{video_id}&related=0" width="#{options[:width]}" height="#{options[:height]}"><param name="movie" value="http://www.dailymotion.com/swf/#{video_id}&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/#{video_id}?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/#{video_id}" width="#{options[:width]}" height="#{options[:height]}"/></a></object></div>}
end
end
11 changes: 7 additions & 4 deletions lib/auto_html/filters/flickr.rb
Expand Up @@ -12,9 +12,12 @@
uri = URI("http://www.flickr.com/services/oembed")
uri.query = URI.encode_www_form(params)

response = JSON.parse(Net::HTTP.get(uri))

link_options = Array(options[:link_options]).reject { |k,v| v.nil? }.map { |k, v| %{#{k}="#{REXML::Text::normalize(v)}"} }.join(' ')
begin
response = JSON.parse(Net::HTTP.get(uri))
link_options = Array(options[:link_options]).reject { |k,v| v.nil? }.map { |k, v| %{#{k}="#{REXML::Text::normalize(v)}"} }.join(' ')
%{<a href="#{match}"#{ ' ' + link_options unless link_options.empty? }><img src="#{response["url"]}" alt="#{response["title"]}" title="#{response["title"]}" /></a>}
rescue JSON::ParserError
match
end
end
end
end
2 changes: 1 addition & 1 deletion lib/auto_html/filters/image.rb
Expand Up @@ -10,7 +10,7 @@ def paragraph(text)
r = Redcarpet::Markdown.new(NoParagraphRenderer)
alt = options[:alt]
options[:proxy] ||= ""
text.gsub(/(?<!src=")https?:\/\/.+?\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
text.gsub(/(?<=^|\s)https?:\/\/.+?\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
r.render("![#{alt}](#{options[:proxy]}#{match})")
end
end
8 changes: 4 additions & 4 deletions lib/auto_html/filters/instagram.rb
Expand Up @@ -2,9 +2,9 @@
require 'net/http'

AutoHtml.add_filter(:instagram) do |text|
text << '/' unless text.end_with?('/')
regex = %r{https?:\/\/(www.)?instagr(am\.com|\.am)/p/.+}
text.gsub(regex) do
%{<iframe src="#{text}embed" height="714" width="616" frameborder="0" scrolling="no"></iframe>}
regex = %r{(^|\s|>)https?:\/\/(www.)?instagr(am\.com|\.am)/p/.+($|\s|<)}
text.gsub(regex) do |match|
match << '/' unless match.end_with?('/')
%{<iframe src="#{match}embed" height="714" width="616" frameborder="0" scrolling="no"></iframe>}
end
end
2 changes: 1 addition & 1 deletion lib/auto_html/filters/liveleak.rb
Expand Up @@ -14,6 +14,6 @@
params << "autoplay=1" if autoplay
params << "rel=0" if hide_related
src += "?#{params.join '&'}" unless params.empty?
%{<iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe>}
%{<div class="video-container liveleak"><iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe></div>}
end
end
6 changes: 3 additions & 3 deletions lib/auto_html/filters/sanitize.rb
@@ -1,5 +1,5 @@
AutoHtml.add_filter(:sanitize).with({}) do |text, options|
require 'action_controller'
require 'cgi'
HTML::WhiteListSanitizer.new.sanitize(text, options)
#require 'action_controller'
#require 'cgi'
Rails::Html::WhiteListSanitizer.new.sanitize(text, options)
end
31 changes: 15 additions & 16 deletions lib/auto_html/filters/soundcloud.rb
Expand Up @@ -3,19 +3,18 @@
# set these options and default values
# :width => '100%', :height => 166, :auto_play => false, :theme_color => '00FF00', :color => '915f33', :show_comments => false
AutoHtml.add_filter(:soundcloud).with(:width => '100%', :height => 166, :auto_play => false, :theme_color => '00FF00', :color => '915f33', :show_comments => false, :show_artwork => false) do |text, options|
require 'uri'
require 'net/http'
text.gsub(/(https?:\/\/)?(www.)?soundcloud\.com\/\S*/) do |match|
new_uri = match.to_s
new_uri = (new_uri =~ /^https?\:\/\/.*/) ? URI(new_uri) : URI("http://#{new_uri}")
new_uri.normalize!
width = options[:width]
height = options[:height]
auto_play = options[:auto_play]
theme_color = options[:theme_color]
color = options[:color]
show_artwork = options[:show_artwork]
show_comments = options[:show_comments]
%{<iframe width="#{width}" height="#{height}" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=#{new_uri}&show_artwork=#{show_artwork}&show_comments=#{show_comments}&auto_play=#{auto_play}&color=#{color}&theme_color=#{theme_color}"></iframe>}
end
end
regex = /(^|\s|>)(https?:\/\/)?(www.)?soundcloud\.com\/\S*($|\s|<)/
text.gsub(regex) do |match|
new_uri = match.to_s
new_uri = (new_uri =~ /^https?\:\/\/.*/) ? new_uri : "http://#{new_uri}"
new_uri.strip!
width = options[:width]
height = options[:height]
auto_play = options[:auto_play]
theme_color = options[:theme_color]
color = options[:color]
show_artwork = options[:show_artwork]
show_comments = options[:show_comments]
%{<iframe width="#{width}" height="#{height}" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=#{new_uri}&show_artwork=#{show_artwork}&show_comments=#{show_comments}&auto_play=#{auto_play}&color=#{color}&theme_color=#{theme_color}"></iframe>}
end
end
2 changes: 1 addition & 1 deletion lib/auto_html/filters/vimeo.rb
Expand Up @@ -10,6 +10,6 @@
query_string_variables = [show_title, show_byline, show_portrait].compact.join("&")
query_string = "?" + query_string_variables unless query_string_variables.empty?

%{<iframe src="//player.vimeo.com/video/#{vimeo_id}#{query_string}" width="#{width}" height="#{height}" frameborder="#{frameborder}"></iframe>}
%{<div class="video-container vimeo"><iframe src="//player.vimeo.com/video/#{vimeo_id}#{query_string}" width="#{width}" height="#{height}" frameborder="#{frameborder}"></iframe></div>}
end
end
2 changes: 1 addition & 1 deletion lib/auto_html/filters/worldstar.rb
Expand Up @@ -3,6 +3,6 @@
video_id = $1
width = options[:width]
height = options[:height]
%{<object width="#{width}" height="#{height}"><param name="movie" value="http://www.worldstarhiphop.com/videos/e/16711680/#{video_id}"><param name="allowFullScreen" value="true"></param><embed src="http://www.worldstarhiphop.com/videos/e/16711680/#{video_id}" type="application/x-shockwave-flash" allowFullscreen="true" width="#{width}" height="#{height}"></embed></object>}
%{<div class="video-container worldstar"><object width="#{width}" height="#{height}"><param name="movie" value="http://www.worldstarhiphop.com/videos/e/16711680/#{video_id}"><param name="allowFullScreen" value="true"></param><embed src="http://www.worldstarhiphop.com/videos/e/16711680/#{video_id}" type="application/x-shockwave-flash" allowFullscreen="true" width="#{width}" height="#{height}"></embed></object></div>}
end
end
6 changes: 3 additions & 3 deletions lib/auto_html/filters/youtube.rb
@@ -1,7 +1,7 @@
AutoHtml.add_filter(:youtube).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil, :autoplay => false, :hide_related => false) do |text, options|
regex = /(https?:\/\/)?(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\?\S+)?/
regex = /(^|\s|>)(https?:\/\/)?(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\?\S+)?($|\s|<)/
text.gsub(regex) do
youtube_id = $4
youtube_id = $5
width = options[:width]
height = options[:height]
frameborder = options[:frameborder]
Expand All @@ -14,6 +14,6 @@
params << "autoplay=1" if autoplay
params << "rel=0" if hide_related
src += "?#{params.join '&'}" unless params.empty?
%{<div class="video youtube"><iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe></div>}
%{#{$1}<div class="video-container youtube"><iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe></div>#{$8}}
end
end
2 changes: 1 addition & 1 deletion test/functional/auto_html_for_options_test.rb
Expand Up @@ -11,7 +11,7 @@ class Post < ActiveRecord::Base
end
end

class AutoHtmlForOptionsTest < Test::Unit::TestCase
class AutoHtmlForOptionsTest < Minitest::Test
include FixtureSetup

def test_transform_after_save
Expand Down
2 changes: 1 addition & 1 deletion test/functional/auto_html_for_test.rb
Expand Up @@ -16,7 +16,7 @@ class Article < ActiveRecord::Base
end
end

class AutoHtmlForTest < Test::Unit::TestCase
class AutoHtmlForTest < Minitest::Test
include FixtureSetup

def test_transform_on_initialization
Expand Down
2 changes: 1 addition & 1 deletion test/functional/filter_test.rb
Expand Up @@ -17,7 +17,7 @@ class User < ActiveRecord::Base
end
end

class FilterTest < Test::Unit::TestCase
class FilterTest < Minitest::Test
include FixtureSetup

def test_transform_after_save
Expand Down
15 changes: 14 additions & 1 deletion test/test_helper.rb
@@ -1,9 +1,22 @@
require 'rubygems'
require 'bundler'
Bundler.setup

require 'test/unit'
require 'active_record'
require 'action_view'
require 'active_support'
require 'active_support/core_ext/class'

require File.dirname(__FILE__) + '/../init'

require 'minitest'
require 'minitest/reporters'
#require 'minitest/focus'

reporter_opts = {color: true, slow_count: 5}

Minitest::Reporters.use!(
[
Minitest::Reporters::DefaultReporter.new(reporter_opts)
]
)
2 changes: 1 addition & 1 deletion test/unit/auto_html_test.rb
@@ -1,7 +1,7 @@
require File.expand_path('../unit_test_helper', __FILE__)


class AutoHtmlTest < Test::Unit::TestCase
class AutoHtmlTest < Minitest::Test

def test_should_be_raw_input_when_no_filters_provided
input = "Hey check out my blog => http://rors.org"
Expand Down
22 changes: 18 additions & 4 deletions test/unit/filters/dailymotion_test.rb
@@ -1,20 +1,34 @@
require File.expand_path('../../unit_test_helper', __FILE__)

class DailyMotionTest < Test::Unit::TestCase
class DailyMotionTest < Minitest::Test

DIV_START = '<div class="video-container dailymotion">'

def test_transform
result = auto_html("http://www.dailymotion.com/en/featured/video/xag4p2_tempsmorttv-episode-01_shortfilms") { dailymotion }
assert_equal '<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/xag4p2_tempsmorttv-episode-01_shortfilms&related=0" width="480" height="360"><param name="movie" value="http://www.dailymotion.com/swf/xag4p2_tempsmorttv-episode-01_shortfilms&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/xag4p2_tempsmorttv-episode-01_shortfilms?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/xag4p2_tempsmorttv-episode-01_shortfilms" width="480" height="360"/></a></object>', result
assert_equal %Q|#{DIV_START}<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/xag4p2_tempsmorttv-episode-01_shortfilms&related=0" width="480" height="360"><param name="movie" value="http://www.dailymotion.com/swf/xag4p2_tempsmorttv-episode-01_shortfilms&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/xag4p2_tempsmorttv-episode-01_shortfilms?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/xag4p2_tempsmorttv-episode-01_shortfilms" width="480" height="360"/></a></object></div>|, result
end

def test_transform_with_tweaked_width
result = auto_html("http://www.dailymotion.com/related/x9cyf6/video/x9tinl_happy-tree-friends-as-you-wish-part_fun") { dailymotion :width => 500 }
assert_equal '<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/x9tinl_happy-tree-friends-as-you-wish-part_fun&related=0" width="500" height="360"><param name="movie" value="http://www.dailymotion.com/swf/x9tinl_happy-tree-friends-as-you-wish-part_fun&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/x9tinl_happy-tree-friends-as-you-wish-part_fun?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/x9tinl_happy-tree-friends-as-you-wish-part_fun" width="500" height="360"/></a></object>', result
assert_equal %Q|#{DIV_START}<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/x9tinl_happy-tree-friends-as-you-wish-part_fun&related=0" width="500" height="360"><param name="movie" value="http://www.dailymotion.com/swf/x9tinl_happy-tree-friends-as-you-wish-part_fun&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/x9tinl_happy-tree-friends-as-you-wish-part_fun?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/x9tinl_happy-tree-friends-as-you-wish-part_fun" width="500" height="360"/></a></object></div>|, result
end

def test_transform_with_options
result = auto_html("http://www.dailymotion.com/video/xakv5i") { dailymotion(:width => 500, :height => 300) }
assert_equal '<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/xakv5i&related=0" width="500" height="300"><param name="movie" value="http://www.dailymotion.com/swf/xakv5i&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/xakv5i?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/xakv5i" width="500" height="300"/></a></object>', result
assert_equal %Q|#{DIV_START}<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/xakv5i&related=0" width="500" height="300"><param name="movie" value="http://www.dailymotion.com/swf/xakv5i&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/xakv5i?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/xakv5i" width="500" height="300"/></a></object></div>|, result
end


def test_prevent_html_transform
str = '<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/xakv5i&related=0" width="500" height="300"><param name="movie" value="http://www.dailymotion.com/swf/xakv5i&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/xakv5i?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/xakv5i" width="500" height="300"/></a></object>'

result = auto_html(str) { dailymotion(:width => 500, :height => 300) }

assert_equal(
str, result,
"Should not re-transform HTML with dailymotion links inside of it"
)
end

end
15 changes: 15 additions & 0 deletions test/unit/filters/flickr_test.rb
@@ -0,0 +1,15 @@
require File.expand_path('../../unit_test_helper', __FILE__)

class FlickrTest < Minitest::Test

def test_transform_success
result = auto_html('https://www.flickr.com/photos/spooky_mayne/15662909077') { flickr }
assert_equal 'https://www.flickr.com/photos/spooky_mayne/15662909077', result
end

def test_bad_url
result = auto_html('http://www.flickr.com/photos/kenami/to') { flickr }
assert_equal 'http://www.flickr.com/photos/kenami/to', result
end

end
2 changes: 1 addition & 1 deletion test/unit/filters/gist_test.rb
@@ -1,6 +1,6 @@
require File.expand_path('../../unit_test_helper', __FILE__)

class GistTest < Test::Unit::TestCase
class GistTest < Minitest::Test

def test_transform
result = auto_html('https://gist.github.com/1710276') { gist }
Expand Down
2 changes: 1 addition & 1 deletion test/unit/filters/google_map_test.rb
@@ -1,6 +1,6 @@
require File.expand_path('../../unit_test_helper', __FILE__)

class GoogleMapTest < Test::Unit::TestCase
class GoogleMapTest < Minitest::Test

def test_transform
result = auto_html('http://maps.google.co.kr/maps?q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A') { google_map }
Expand Down
2 changes: 1 addition & 1 deletion test/unit/filters/hashtag_test.rb
@@ -1,6 +1,6 @@
require File.expand_path('../../unit_test_helper', __FILE__)

class HashtagTest < Test::Unit::TestCase
class HashtagTest < Minitest::Test

def test_transform
result = auto_html("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ipsum et leo adipiscing ultrices. Etiam ac elementum cras amet. #LoremIpsum") { hashtag }
Expand Down
2 changes: 1 addition & 1 deletion test/unit/filters/html_escape_test.rb
@@ -1,6 +1,6 @@
require File.expand_path('../../unit_test_helper', __FILE__)

class HtmlEscapeTest < Test::Unit::TestCase
class HtmlEscapeTest < Minitest::Test

def test_trasform
result = auto_html("<script>alert(0)</script>") { html_escape }
Expand Down
14 changes: 13 additions & 1 deletion test/unit/filters/image_test.rb
@@ -1,6 +1,6 @@
require File.expand_path('../../unit_test_helper', __FILE__)

class ImageTest < Test::Unit::TestCase
class ImageTest < Minitest::Test

def test_transform
result = auto_html('http://rors.org/images/rails.png') { image({:alt => nil}) }
Expand Down Expand Up @@ -52,6 +52,18 @@ def test_transform8
assert_equal 'Which do you prefer, this one <img src="http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG" alt=""/>, or this one <img src="http://rors.org/images/rails.png" alt=""/>?', result
end

def test_markdown_not_transformed
img_markdown = "![GOOG logo](http://www.google.com/images/srpr/logo11w.png)"
result = auto_html(img_markdown) { image }
assert_equal img_markdown, result
end

def test_image_tag_not_transformed
result = auto_html('<img src="http://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png" />') { image }
assert_equal '<img src="http://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png" />', result
end


def test_https
result = auto_html('https://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png') { image({:alt => nil}) }
assert_equal '<img src="https://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png" alt=""/>', result
Expand Down