[Bug #541] cgi.rb : obsolete regex "n" option

Bug #541: cgi.rb : obsolete regex “n” option
http://redmine.ruby-lang.org/issues/show/541

e$B5/I<<Te(B: Takeyuki F.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal

CGI::[email protected],I=8=ItJ,$Ke(Bne$B$,;H$o$l$F$$$k$N$Ge(B
warninge$B$,=P$^$9!#e(B
Index: lib/cgi.rb

— lib/cgi.rb (e$B%j%S%8%g%se(B 19071)
+++ lib/cgi.rb (e$B:n6H%3%T!<e(B)
@@ -1245,14 +1245,14 @@

#

def CGI::pretty(string, shift = " ")

  • lines = string.gsub(/(?!\A)<(?:.|\n)?>/n,
    “\n\0”).gsub(/<(?:.|\n)
    ?>(?!\n)/n, “\0\n”)
  • lines = string.gsub(/(?!\A)<(?:.|\n)?>/,
    “\n\0”).gsub(/<(?:.|\n)
    ?>(?!\n)/, “\0\n”)
    end_pos = 0
  • while end_pos = lines.index(/^</(\w+)/n, end_pos)
  • while end_pos = lines.index(/^</(\w+)/, end_pos)
    element = $1.dup
  •  start_pos = lines.rindex(/^\s*<#{element}/ni, end_pos)
    
  •  lines[start_pos ... end_pos] = "__" + lines[start_pos ... 
    

end_pos].gsub(/\n(?!\z)/n, “\n” + shift) + “__”

  •  start_pos = lines.rindex(/^\s*<#{element}/i, end_pos)
    
  •  lines[start_pos ... end_pos] = "__" + lines[start_pos ... 
    

end_pos].gsub(/\n(?!\z)/, “\n” + shift) + “__”
end

  • lines.gsub(/^((?:#{Regexp::quote(shift)})*)__(?=</?\w)/n, ‘\1’)
  • lines.gsub(/^((?:#{Regexp::quote(shift)})*)__(?=</?\w)/, ‘\1’)
    end

e$B%A%1%C%He(B #541 e$B$,99?7$5$l$^$7$?!#e(B (by Takeyuki F.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r19245.

http://redmine.ruby-lang.org/issues/show/541

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs