[Manager] Add HTML TOU support to Wizard

Moved part xml_unescape to gui_rpc_client_ops.cpp closer to its parsing

Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
This commit is contained in:
Vitalii Koshura 2018-06-05 01:26:42 +03:00
parent 411ff5571b
commit 8ef9bb3b51
No known key found for this signature in database
GPG Key ID: CE0DB1726070A5A3
3 changed files with 15 additions and 10 deletions

View File

@ -224,14 +224,10 @@ void CTermsOfUsePage::OnPageChanged( wxWizardExEvent& event ) {
_("Please read the following terms of use:")
);
std::string tou = pc.terms_of_use;
xml_unescape(tou);
wxString terms_of_use(tou.c_str(), wxConvUTF8);
// HTML TOU can have no open/close html tags
// so I see no proper way to identify
// whether it is html or plain text
// and I have to use this dirty hack
if (pc.terms_of_use == tou) {
wxString terms_of_use(pc.terms_of_use.c_str(), wxConvUTF8);
// We need to replace all line endings in text TOU
// to make it looks properly in HTML Window
if (!pc.terms_of_use_is_html) {
terms_of_use.Replace("\r\n", "<br>");
terms_of_use.Replace("\r", "<br>");
terms_of_use.Replace("\n", "<br>");

View File

@ -1,6 +1,6 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2018 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -554,6 +554,7 @@ struct PROJECT_CONFIG {
bool web_stopped; // DB-driven web functions disabled
int min_client_version;
std::string error_msg;
bool terms_of_use_is_html;
std::string terms_of_use;
// if present, show this text in an "accept terms of use?" dialog
// before allowing attachment to continue.

View File

@ -1,6 +1,6 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2018 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -1323,7 +1323,14 @@ int PROJECT_CONFIG::parse(XML_PARSER& xp) {
if (xp.match_tag("terms_of_use")) {
char buf[65536];
if (!xp.element_contents("</terms_of_use>", buf, sizeof(buf))) {
// HTML TOU can have no open/close html tags
// so I see no proper way to identify
// whether it is html or plain text
// and I have to use this dirty hack
const string tou = buf;
xml_unescape(buf);
terms_of_use = buf;
terms_of_use_is_html = terms_of_use != tou;
}
continue;
}
@ -1345,6 +1352,7 @@ void PROJECT_CONFIG::clear() {
master_url.clear();
web_rpc_url_base.clear();
error_msg.clear();
terms_of_use_is_html = false;
terms_of_use.clear();
local_revision = 0;
min_passwd_length = 6;