From 2de33c25310ead5475b3a8683721e2e7101a1167 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Thu, 26 Mar 2020 16:19:11 +0100 Subject: [PATCH] Preserve webserver from wasting time in re-constructing output message for RfCs --- app/views/request_for_comments/show.html.slim | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/views/request_for_comments/show.html.slim b/app/views/request_for_comments/show.html.slim index a68075c3..3cf276ea 100644 --- a/app/views/request_for_comments/show.html.slim +++ b/app/views/request_for_comments/show.html.slim @@ -40,12 +40,17 @@ - output_runs.each do |testrun| - output = testrun.try(:output) - if output - // (?:\\"|.) is required to correctly identify " within the output. - - messages = output.scan(/{(?:(?:"(?:\\"|.)+?":"(?:\\"|.)+?")+?,?)+}/) - - messages.map! {|el| JSON.parse(el)} - - messages.keep_if {|message| message['cmd'] == 'write'} - - messages.map! {|message| message['data']} - - output = messages.join '' + - puts output + - begin + - Timeout::timeout(2) do + // (?:\\"|.) is required to correctly identify " within the output. + // The outer (?: |\d+?) is used to correctly identify integers within the JSON + - messages = output.scan(/{(?:(?:"(?:\\"|.)+?":(?:"(?:\\"|.)+?"|\d+?|\[.*?\]))+?,?)+}/) + - messages.map! {|el| JSON.parse(el)} + - messages.keep_if {|message| message['cmd'] == 'write'} + - messages.map! {|message| message['data']} + - output = messages.join '' + - rescue Timeout::Error pre= output or t('request_for_comments.no_output') - assess_runs = testruns.select {|run| run.cause == 'assess'}