Parse archive-contents file more rigorously when building the html index (fixes #49)

This commit is contained in:
Steve Purcell 2012-04-16 13:50:08 +01:00
parent 466327d532
commit ca5fdf6ea9

View file

@ -17,7 +17,7 @@
<% <%
def parse str def parse str
# credit to: http://stackoverflow.com/q/3128406/154508 # credit to: http://stackoverflow.com/q/3128406/154508
tokens = str.scan(/#{Regexp.escape("(")}|#{Regexp.escape(")")}|[a-zA-Z0-9\'\-\_\+]+/) tokens = str.scan(/#{Regexp.escape("(")}|#{Regexp.escape(")")}|"(?:\\.|[^"])+"|[a-zA-Z0-9\'\-\_\+]+/)
stack = [[]] stack = [[]]
@ -27,6 +27,8 @@
stack << [] stack << []
when ")" when ")"
stack[-2] << stack.pop stack[-2] << stack.pop
when /^"(.*)\"$/
stack[-1] << $1
else else
stack[-1] << tok stack[-1] << tok
end end