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;

View File

@ -202,10 +202,10 @@ static bool parse_version(FILE* f, char* new_version, int len) {
if (xp.match_tag("/version")) {
#ifdef __APPLE__
return (same_platform
&& newer_version_exists
&& min_macos_OK
&& max_macos_OK
);
&& newer_version_exists
&& min_macos_OK
&& max_macos_OK
);
#else
return (same_platform && newer_version_exists);
#endif
@ -215,11 +215,11 @@ static bool parse_version(FILE* f, char* new_version, int len) {
}
if (xp.parse_str("version_num", buf2, sizeof(buf2))) {
newer_version_exists = is_version_newer(
buf2,
gstate.core_client_version.major,
gstate.core_client_version.minor,
gstate.core_client_version.release
);
buf2,
gstate.core_client_version.major,
gstate.core_client_version.minor,
gstate.core_client_version.release
);
strlcpy(new_version, buf2, len);
}
#ifdef __APPLE__
@ -307,10 +307,10 @@ void newer_version_startup_check() {
if (!gstate.newer_version.empty()) {
if (is_version_newer(gstate.newer_version.c_str(),
gstate.core_client_version.major,
gstate.core_client_version.minor,
gstate.core_client_version.release)
) {
gstate.core_client_version.major,
gstate.core_client_version.minor,
gstate.core_client_version.release)
) {
show_newer_version_msg(gstate.newer_version.c_str());
} else {
gstate.newer_version = "";