Skip to content

Commit

Permalink
sim, sip, simlib: escape checker output into a valid UTF-8 string
Browse files Browse the repository at this point in the history
  • Loading branch information
varqox committed Oct 13, 2024
1 parent ef89604 commit 7c569a4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion subprojects/sim/src/job_server/job_handlers/judge_logger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstdint>
#include <optional>
#include <simlib/concat_tostr.hh>
#include <simlib/escape_bytes_to_utf8_str.hh>
#include <simlib/from_unsafe.hh>
#include <simlib/sim/judge/test_report.hh>
#include <simlib/sim/judge_worker.hh>
Expand Down Expand Up @@ -80,7 +81,7 @@ public:
case sim::JudgeReport::Test::SKIPPED: back_insert(line, "\033[1;36mSKIPPED\033[m"); break;
}
if (!test_report.comment.empty()) {
back_insert(line, " (", test_report.comment, ')');
back_insert(line, " (", escape_bytes_to_utf8_str("", test_report.comment, ""), ')');
}

back_insert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sim/submissions/submission.hh>
#include <sim/submissions/update_final.hh>
#include <simlib/concat_tostr.hh>
#include <simlib/escape_bytes_to_utf8_str.hh>
#include <simlib/macros/stack_unwinding.hh>
#include <simlib/sim/judge_worker.hh>
#include <simlib/string_transform.hh>
Expand Down Expand Up @@ -298,7 +299,7 @@ void judge_or_rejudge_submission(
"<li><span class=\"test-id\">",
html_escape(test.name),
"</span>",
html_escape(test.comment),
html_escape(escape_bytes_to_utf8_str("", test.comment, "")),
"</li>"
);
}
Expand Down
5 changes: 3 additions & 2 deletions subprojects/simlib/include/simlib/sim/judge_worker.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstdint>
#include <memory>
#include <simlib/concat.hh>
#include <simlib/escape_bytes_to_utf8_str.hh>
#include <simlib/file_manip.hh>
#include <simlib/file_path.hh>
#include <simlib/logger.hh>
Expand Down Expand Up @@ -115,7 +116,7 @@ public:

// Comment
if (!test.comment.empty()) {
back_insert(res, ' ', test.comment, '\n');
back_insert(res, ' ', escape_bytes_to_utf8_str("", test.comment, ""), '\n');
} else {
res += '\n';
}
Expand Down Expand Up @@ -299,7 +300,7 @@ public:
case JudgeReport::Test::SKIPPED: tmplog("\033[1;36mSKIPPED\033[m"); break;
}
if (!test_report.comment.empty()) {
tmplog(" (", test_report.comment, ')');
tmplog(" (", escape_bytes_to_utf8_str("", test_report.comment, ""), ')');
}

// Rest
Expand Down
3 changes: 2 additions & 1 deletion subprojects/simlib/src/sim/judge/test_on_interactive_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ TestReport test_on_interactive_test(InteractiveTestArgs args) {
}

if (prog_res.cgroup.peak_memory_in_bytes > args.program.memory_limit_in_bytes) {
report.status = TestReport::Status::MemoryLimitExceeded, report.comment = "";
report.status = TestReport::Status::MemoryLimitExceeded;
report.comment = "";
report.score = 0;
return report;
}
Expand Down
3 changes: 2 additions & 1 deletion subprojects/simlib/src/sim/judge/test_on_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ TestReport test_on_test(TestArgs args) {
}

if (prog_res.cgroup.peak_memory_in_bytes > args.program.memory_limit_in_bytes) {
report.status = TestReport::Status::MemoryLimitExceeded, report.comment = "";
report.status = TestReport::Status::MemoryLimitExceeded;
report.comment = "";
return report;
}

Expand Down
2 changes: 1 addition & 1 deletion subprojects/simlib/test/conver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class TestingJudgeLogger : public sim::JudgeLogger {
if (pos != decltype(normalized_comment)::npos) {
normalized_comment.replace(pos, STR_TO_REPLACE.size(), " killed by signal ");
}
log(" (", normalized_comment, ")");
log(" (", escape_bytes_to_utf8_str("", normalized_comment, ""), ")");
}
if (judge_test_report.checker) {
log(" Checker: ");
Expand Down
3 changes: 2 additions & 1 deletion subprojects/sip/src/sip_judge_logger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstdint>
#include <map>
#include <simlib/enum_val.hh>
#include <simlib/escape_bytes_to_utf8_str.hh>
#include <simlib/humanize.hh>
#include <simlib/sim/judge_worker.hh>
#include <simlib/sim/simfile.hh>
Expand Down Expand Up @@ -98,7 +99,7 @@ public:
}

if (!test_report.comment.empty()) {
tmplog(" (", test_report.comment, ')');
tmplog(" (", escape_bytes_to_utf8_str("", test_report.comment, ""), ')');
}

// Rest
Expand Down

0 comments on commit 7c569a4

Please sign in to comment.