From: Ruby Ruby Date: 2012-06-11T17:52:08+09:00 Subject: cgi class prints garbage in HTML output Hi everybody I am trying to bring an Web App up in ruby 1.9.3 which worked flawlessly in ruby 1.8.7. But sofar, I am stumbling from one failure to the next. At some point it seems to me as if the cgi class would write everything it gets hands on to the HTML output, which makes that the HTML output is unusable, to say the least. Note that in the following ruby code snippet @c is the actual cgi-class. This is the code which generates the main HTML table (table3): nf = rf.length # total number of fields to display noc = @sess["noc"].to_i nor = nf/noc # total number of rows to display ncta = (CHARS_TEXTAREA / noc).to_s # cols in the textarea if nrr == 1 # must be one single row @c.tablen("class"=>"ps") { "#{ (0..nor).collect { |rct| # field names @c.tr{ "#{ rf[rct*noc, noc].collect { |nf| # field name nt = @dbx.tat[nf].to_s # field type @sess["aeq"].include?(nf) ? nf = @sess["aeq"][nf] : nf = _(nf) @c.th("class"=>"tah") {"#{nf} (#{nt})"} } }" }+"\n"+ @c.tr{ # field content "#{ rf[rct*noc, noc].collect { |nf| # field name nt = @dbx.tat[nf].to_s # field type nr = rr[nf] # field value if nf.match(/date_(next|last)_action/) nr = Time.now.strftime("%Y-%m-%d") end nx = CGI::unescape(nr) nrta = ROWS_NEW_TEXTAREA.to_s cmds[nt].call(ncta, nrta, nf, nx, nr) } }" } } }"+"\n" } And this is the generated HTML code. Note that I manually inserted the line feeds into the HTML text, to make it readable. In the original, all is on one single line. [" [\"\", \"\", \" \", \" \", \" \"]\n [\"\", \"\", \"\", \"\", \"\"] ", "[\"\", \"\", \"\", \"\", \"\"]\n[\"\", \"\", \"\", \"\", \"\"]", "[\"\", \"\", \"\", \"\"]\n[\"\", \"\", \"\", \"\"]"]
task_name (text)actiony (text)date_start (date)date_end (date)period (int(4) unsigned)
\\n \\n \\n \\n \\n
next_period (date)date_last_action (date)date_next_action (date)start_time (time)end_time (time)
\\n\\n\\n\\n\\n
task_address (text)task_comment (text)task_responsible (text)project (text)
\\n\\n\\n\\n
Has someone had such problems as well with ruby 1.9.3? I already mentionned that the above ruby code worked fine in ruby 1.8.7. What do I need to change to prohibit the multi-escaping of each item? Thanks very much for any idea. suomi -- Posted via http://www.ruby-forum.com/.