config/initializers/core_extensions_2.rb
# Note that I change strong to b, 'cause strong appears to be overridden in our CSS.  Hrmph.
Note that I change strong to b, 'cause strong appears to be overridden in our CSS.  Hrmph.
Note that I change strong to b ' cause strong appears to be overridden in our CSS . Hrmph .
def allow_some_html
    @allowed_attributes_in_allow_some_html = /\s*\/|\s+href=['"][^'"]+['"]/
    start_tag   = /</
    end_tag     = />/
    line_breaks = /\r\n/
    text = self.gsub(start_tag, '&lt;')
    text.gsub!(end_tag, '&gt;')
    ['a', 'b', 'blockquote', 'br', 'em', 'i', 'p', 'small', 'strong', 'cite'].each do |tag|
      tag_regex = /&lt;(\/)?#{tag}(#{@allowed_attributes_in_allow_some_html})?\s*&gt;/i
      text.gsub!(tag_regex, "<\\1#{tag.gsub(/strong/, 'b')}\\2>")
      text.gsub!(/<a href/, '<a rel="nofollow" href')
    end
    unless text.match(/<(br|p)\s*[\/]?\s*>/)
      text.gsub!(line_breaks, '<br/>')
    end
    return text
  end
def allow_some_html @allowed_attributes_in_allow_some_html = / \s * \/ | \s +href=['"][^'"]+['"] / start_tag = / < / end_tag = / > / line_breaks = / \r \n / text = self . gsub ( start_tag , '&lt;' ) text . gsub! ( end_tag , '&gt;' ) [ 'a' , 'b' , 'blockquote' , 'br' , 'em' , 'i' , 'p' , 'small' , 'strong' , 'cite' ] . each do | tag | tag_regex = / &lt;( \/ )? #{ tag } ( #{ @allowed_attributes_in_allow_some_html } )? \s *&gt; /i text . gsub! ( tag_regex , "<\\1#{tag.gsub(/strong/, 'b')}\\2>" ) text . gsub! ( / <a href / , '<a rel="nofollow" href' ) end unless text . match ( / <(br|p) \s *[ \/ ]? \s *> / ) text . gsub! ( line_breaks , '<br/>' ) end return text end
Note that I change strong to b, 'cause strong appears to be overridden in our CSS.
Note that I change strong to b ' cause strong appears to be overridden in our CSS .
# inline RegEx passed to gsub calls leak memory! We declare them first: