GUI RPC: enclose message bodies in CDATA to avoid XML parse errors

for messages containing "<".

Also strip off <?xml tag from project config
to make GUI RPC reply valid.
This commit is contained in:
David Anderson 2016-04-05 13:14:21 -07:00
parent 36dcf816c5
commit 1fe02c9d4f
5 changed files with 9 additions and 11 deletions

View File

@ -409,7 +409,7 @@ int ACCT_MGR_OP::parse(FILE* f) {
}
if (log_flags.unparsed_xml) {
msg_printf(NULL, MSG_INFO,
"[unparsed_xml] ACCT_MGR_OP::parse: unrecognized tag <%s/>",
"[unparsed_xml] ACCT_MGR_OP::parse: unrecognized tag <%s>",
xp.parsed_tag
);
}

View File

@ -217,7 +217,7 @@ void MESSAGE_DESCS::write(int seqno, MIOFILE& fout, bool translatable) {
" <project>%s</project>\n"
" <pri>%d</pri>\n"
" <seqno>%d</seqno>\n"
" <body>\n%s\n</body>\n"
" <body><![CDATA[\n%s\n]]></body>\n"
" <time>%d</time>\n",
mdp->project_name,
mdp->priority,

View File

@ -774,7 +774,10 @@ void handle_get_project_config_poll(GUI_RPC_CONN& grc) {
grc.get_project_config_op.error_num
);
} else {
grc.mfout.printf("%s", grc.get_project_config_op.reply.c_str());
const char *p = grc.get_project_config_op.reply.c_str();
const char *q = strstr(p, "<project_config");
if (!q) q = "<project_config/>\n";
grc.mfout.printf("%s", q);
}
}

View File

@ -457,7 +457,7 @@ int CC_CONFIG::parse_options_client(XML_PARSER& xp) {
msg_printf_notice(NULL, false,
"http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config",
"%s: <%s/>",
"%s: <%s>",
_("Unrecognized tag in cc_config.xml"),
xp.parsed_tag
);
@ -512,7 +512,7 @@ int CC_CONFIG::parse_client(FILE* f) {
if (xp.match_tag("log_flags/")) continue;
msg_printf_notice(NULL, false,
"http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config",
"%s: <%s/>",
"%s: <%s>",
_("Unrecognized tag in cc_config.xml"),
xp.parsed_tag
);

View File

@ -821,15 +821,10 @@ MESSAGE::MESSAGE() {
}
int MESSAGE::parse(XML_PARSER& xp) {
char buf[1024];
while (!xp.get_tag()) {
if (xp.match_tag("/msg")) return 0;
if (xp.parse_string("project", project)) continue;
if (xp.match_tag("body")) {
xp.element_contents("</body>", buf, sizeof(buf));
body = buf;
continue;
}
if (xp.parse_string("body", body)) continue;
if (xp.parse_int("pri", priority)) continue;
if (xp.parse_int("time", timestamp)) continue;
if (xp.parse_int("seqno", seqno)) continue;