1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

remove PercentScanner. fixed % after %> bug. [ruby-dev:37751] [Bug #997]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
seki 2009-01-11 07:58:02 +00:00
parent 832740d15c
commit 2d53925643
3 changed files with 11 additions and 34 deletions

View file

@ -1,3 +1,10 @@
Sun Jan 11 16:53:14 2009 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/erb.rb (PercentScanner): remove PercentScanner. fixed % after
%> bug. [ruby-dev:37751] [Bug #997]
* test/erb/test_erb.rb: ditto
Sun Jan 11 09:53:01 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/mkconstants.rb (c_str): get rid of a 1.9 feature for

View file

@ -444,40 +444,6 @@ class ERB
end
Scanner.regist_scanner(SimpleScanner2, nil, false)
class PercentScanner < Scanner # :nodoc:
def scan(&blk)
stag_reg = /(.*?)(^%%|^%|<%%|<%=|<%#|<%|\z)/m
etag_reg = /(.*?)(%%>|%>|\z)/m
scanner = StringScanner.new(@src)
while ! scanner.eos?
scanner.scan(@stag ? etag_reg : stag_reg)
yield(scanner[1])
elem = scanner[2]
if elem == '%%'
yield('%')
inline_scan(scanner.scan(/.*?(\n|\z)/), &blk)
elsif elem == '%'
yield(PercentLine.new(scanner.scan(/.*?(\n|\z)/).chomp))
else
yield(elem)
end
end
end
def inline_scan(line)
stag_reg = /(.*?)(<%%|<%=|<%#|<%|\z)/m
etag_reg = /(.*?)(%%>|%>|\z)/m
scanner = StringScanner.new(line)
while ! scanner.eos?
scanner.scan(@stag ? etag_reg : stag_reg)
yield(scanner[1])
yield(scanner[2])
end
end
end
Scanner.regist_scanner(PercentScanner, nil, true)
class ExplicitScanner < Scanner # :nodoc:
def scan
stag_reg = /(.*?)(^[ \t]*<%-|<%%|<%=|<%#|<%-|<%|\z)/m

View file

@ -442,6 +442,10 @@ EOS
assert_equal("%A5%B5%A5%F3%A5%D7%A5%EB",
ERB::Util.url_encode("\xA5\xB5\xA5\xF3\xA5\xD7\xA5\xEB".force_encoding("EUC-JP")))
end
def test_percent_after_etag
assert_equal("1%", @erb.new("<%= 1 %>%", nil, "%").result)
end
end
class TestERBCoreWOStrScan < TestERBCore