Mercurial > hgrepos > hgweb.cgi > after5
changeset 32:d23a2b3c456b draft
Save schedule text `as is' in a file and escape them for browser.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 03 Apr 2012 17:08:03 +0900 |
parents | aceb533dfa32 |
children | 844e2f9a037f |
files | after5.rb |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/after5.rb Tue Apr 03 16:28:00 2012 +0900 +++ b/after5.rb Tue Apr 03 17:08:03 2012 +0900 @@ -5,7 +5,7 @@ # (C)2003, 2004, 2006, 2008, 2012 by HIROSE Yuuji [yuuji<at>gentei.org] # $Id: after5.rb,v 1.19 2012/04/01 11:52:25 yuuji Exp yuuji $ # $HGid$ -# Last modified Tue Apr 3 16:27:10 2012 on firestorm +# Last modified Tue Apr 3 17:04:06 2012 on firestorm # See http://www.gentei.org/~yuuji/software/after5/ # このスクリプトはEUCで保存してください。 @@ -1319,6 +1319,10 @@ def decode(string) string.gsub(/\+/, ' ').gsub(/%(..)/){[$1.hex].pack("c")} end + def escape(string) + string.gsub(/&/n, '&').gsub(/\"/n, '"'). + gsub(/>/n, '>').gsub(/</n, '<') + end def gencookie(name, a, expire) x = a.collect{|k, v| @@ -1667,7 +1671,7 @@ if !s.empty? s.keys.sort.collect{|time| s[time].keys.sort.collect{|who| - text = decode(s[time][who]['sched']) + text = escape(s[time][who]['sched']) topic = sprintf "%s%s", time == @opt['alldaydir'] ? '' : time+":", if personal @@ -1835,7 +1839,7 @@ @opt['tdskip'] end } + \ - @H.element("td"){decode(s[time][who]['sched'])} + @H.element("td"){escape(s[time][who]['sched'])} } }.join("\n") } @@ -1876,7 +1880,8 @@ r << s[time].keys.collect{|who| editable = (user==who || @sc.ismember(user, who)) groupp = grepgroup(who) - sprintf("%-5s %-10s %s", tstr, nickname(who), s[time][who]['sched']) + sprintf("%-5s %-10s %s", + tstr, nickname(who), escape(s[time][who]['sched'])) }.join("\n") + "\n" end r << "-" * cols + "\n" @@ -2233,8 +2238,10 @@ return nil end begin - (text = decode(@params['schedule']).strip.gsub(/\r+\n/, $/)) << "\n" - text = purify(text) + + (text = @params['schedule'].toeuc.strip.gsub(/\r+\n/, $/)) << "\n" + # text = purify(text) + STDERR.print text replace = (/modify/i =~ @params['editmode']) rc = @sc.register(registerer, y, m, d, timedir, text, replace) if @params['pub'] && /yes/ =~ @params['pub'] @@ -2315,7 +2322,7 @@ outputError "%s %s", datetime, msg('noplan') return nil end - text = decode(text) + ## text = decode(text) @O.print @H.elementln("h1"){ sprintf "%s %s", datetime, msg(editmode) }