fix bug where if youtube_maps or vimeo_maps were passed in as explicitly nil, the app would 500. #somethingididnotknow (Hash#fetch is kind of weird

This commit is contained in:
Maxwell Salzberg 2011-09-01 10:13:47 -07:00
parent 9cff210b24
commit 7d96b603d3
2 changed files with 14 additions and 2 deletions

View file

@ -10,8 +10,8 @@ module Diaspora
@newlines = options.fetch(:newlines, true)
@specialchars = options.fetch(:specialchars, true)
@youtube_maps = options.fetch(:youtube_maps, {})
@vimeo_maps = options.fetch(:vimeo_maps, {})
@youtube_maps = options[:youtube_maps]||{}
@vimeo_maps = options[:vimeo_maps] || {}
end
def autolink(link, type)

View file

@ -7,6 +7,18 @@ require 'spec_helper'
describe MarkdownifyHelper do
describe "#markdownify" do
it 'does not error if youtube_maps in the hash is explicitly set to nil' do
expect{
markdownify("http://www.youtube.com/watch?v=pZROlhHOvuo", :youtube_maps => nil)
}.should_not raise_error
end
it 'does not error if youtube_maps in the hash is explicitly set to nil' do
expect{
markdownify("http://vimeo.com/18589934", :vimeo_maps => nil)
}.should_not raise_error
end
describe "autolinks" do
it "should not allow basic XSS/HTML" do
markdownify("<script>alert('XSS is evil')</script>").should == "&lt;script&gt;alert('XSS is evil')&lt;/script&gt;"