lib/ab_admin/utils.rb in ab_admin-0.5.0 vs lib/ab_admin/utils.rb in ab_admin-0.6.0

- old
+ new

@@ -57,11 +57,11 @@ # html like: '<!-- html comment --><script>script content</script><div>div content</div><p>p content</p>' # normalized to: "<p>div content</p><p>p content</p>" def normalize_html(raw_html, options = {}, &block) @@sanitizer ||= Sanitizer.new(options) - @@sanitizer.normalize_html(raw_html, &block) + @@sanitizer.normalize_html(raw_html, options[:sanitize] || {}, &block) end def url_helpers Rails.application.routes.url_helpers end @@ -91,14 +91,14 @@ def initialize(options = {}) @options = options end - def normalize_html(raw_html) + def normalize_html(raw_html, options = {}) return '' if raw_html.blank? cleaned_html = raw_html.gsub(CLEAN_HTML_COMMENTS_REGEXP, '')#.gsub(CLEAN_LINE_BREAKS_REGEXP, '<br/>') - html = sanitize(cleaned_html, @options[:sanitize] || {}) + html = sanitize(cleaned_html, options || {}) doc = Nokogiri::HTML.fragment(html) #doc.xpath('comment()').each { |c| c.remove } yield doc if block_given? doc.search('div').each { |el| el.name = 'p' } doc.to_html @@ -140,9 +140,9 @@ def test_env? Rails.env.test? || Rails.env.cucumber? end def friendly_token(n=10) - SecureRandom.base64(16).tr('+/=', 'xyz').first(n) + SecureRandom.base64(n * 2).tr('+/=', 'xyz').first(n) end end end