lib/card/content/clean.rb in card-1.101.4 vs lib/card/content/clean.rb in card-1.101.5

- old
+ new

@@ -44,20 +44,21 @@ ## and attributes outside of the allowed list. def clean_tags string, ok_tags # $LAST_MATCH_INFO is nil if string is a SafeBuffer string.to_str.gsub(%r{<(/*)(\w+)([^>]*)>}) do |_raw| clean_tag $LAST_MATCH_INFO, ok_tags - end.gsub(/<\!--.*?-->/, "") + end.gsub(/<!--.*?-->/, "") end def clean_spaces string string.gsub(/(?:^|\b) ((?:&nbsp;)+)/, '\1 ') end def clean_tag match, ok_tags tag = match[2].downcase return " " unless (ok_attrs = ok_tags[tag]) + "<#{match[1]}#{html_attribs tag, match[3], ok_attrs}>" end def html_attribs tag, raw_attr, ok_attrs ok_attrs.each_with_object([tag]) do |ok_attr, pcs| @@ -68,19 +69,19 @@ def process_attribute attrib, all_attributes return ['"', nil] unless all_attributes =~ /\b#{attrib}\s*=\s*(?=(.))/i q = '"' - rest_value = $' + rest_value = Regexp.last_match.post_match if (idx = %w[' "].index Regexp.last_match(1)) q = Regexp.last_match(1) end reg_exp = ATTR_VALUE_RE[idx || 2] rest_value = process_attribute_match rest_value, reg_exp, attrib [q, rest_value] end - # NOTE allows classes beginning with "w-" (deprecated) + # 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"