lib/card/content/clean.rb in card-1.96.8 vs lib/card/content/clean.rb in card-1.97.0

- old
+ new

@@ -1,14 +1,14 @@ class Card class Content # tools for cleaning content, especially for restricing unwanted HTML module Clean allowed_tags = {} - %w( + %w[ br i b pre cite caption strong em ins sup sub del ol hr ul li p div h1 h2 h3 h4 h5 h6 span table tr td th tbody thead tfoot - ).each { |tag| allowed_tags[tag] = [] } + ].each { |tag| allowed_tags[tag] = [] } # allowed attributes allowed_tags.merge!( "a" => %w[href title target], "img" => %w[src alt title], @@ -59,10 +59,11 @@ alias_method_chain :clean!, :space_last end def process_attribute attrib, all_attributes return ['"', nil] unless all_attributes =~ /\b#{attrib}\s*=\s*(?=(.))/i + q = '"' rest_value = $' if (idx = %w[' "].index Regexp.last_match(1)) q = Regexp.last_match(1) end @@ -72,9 +73,10 @@ end # NOTE allows classes beginning with "w-" (deprecated) def process_attribute_match rest_value, reg_exp, attrib return rest_value unless (match = rest_value.match reg_exp) + rest_value = match[0] if attrib == "class" rest_value.split(/\s+/).select { |s| s =~ /^w-/i }.join(" ") else rest_value