client: don't put HTML in event log messages

(affects only 'new client version' message AFAIK)
This commit is contained in:
David Anderson 2024-07-06 02:11:37 -07:00
parent d1fc269985
commit 8a68fc164a
2 changed files with 34 additions and 22 deletions

View File

@ -62,13 +62,8 @@ void show_message(
//
diagnostics_cycle_logs();
strlcpy(message, msg, sizeof(message));
// trim trailing \n's
//
while (strlen(message) && message[strlen(message)-1] == '\n') {
message[strlen(message)-1] = 0;
}
safe_strcpy(message, msg);
strip_whitespace(message);
// add a message
//
@ -84,9 +79,22 @@ void show_message(
default:
strlcpy(event_msg, message, sizeof(event_msg));
}
// The event log doesn't display HTML, so strip tags
// The only case of this is
// A new version of BOINC is available (8.0.2). <a href=https://boinc.berkeley.edu/download.php>Download</a>
// so do it in a crude way.
//
if (is_html) {
char *q = strchr(event_msg, '<');
if (q) {
*q = 0;
strip_whitespace(event_msg);
}
}
message_descs.insert(p, priority, (int)t, event_msg);
// add a notice
// add a notice if needed
//
switch (priority) {
case MSG_USER_ALERT:
@ -151,7 +159,11 @@ void msg_printf(PROJ_AM *p, int priority, const char *fmt, ...) {
show_message(p, buf, priority, true, 0);
}
void msg_printf_notice(PROJ_AM *p, bool is_html, const char* link, const char *fmt, ...) {
void msg_printf_notice(
PROJ_AM *p,
bool is_html, // msg has HTML tags; don't XML-escape it
const char* link, const char *fmt, ...
) {
char buf[8192]; // output can be much longer than format
va_list ap;