-
Notifications
You must be signed in to change notification settings - Fork 457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: fix xml_escape(), again #2811
Conversation
Test code: // cl /MDd /W4 /EHsc test-xml_escape.cpp /I \dev\boinc\src\lib /I /dev/boinc/src/win_build /link /libpath:\dev\boinc\src\win_build\Build\x64\Debug libboinc.lib shell32.lib advapi32.lib
#include <iostream>
#include <string>
#include "parse.h"
using namespace std;
void test(string str) {
char out[2000] = "";
cout << "test: '" << str << "'\n";
xml_escape(str.c_str(), out, sizeof(out));
cout << "escaped: '" << out << "'\n";
xml_unescape(out);
cout << "unescaped: '" << out << "'\n";
cout << "test==unescaped: " << (str == out) << "\n\n";
}
int main() {
test("");
test("abc");
test("abc<def");
test("abc&def");
test("abc]]>def");
test("<");
test("&");
test("]]>");
test("]");
test("abc]def");
test("abc]]]>def");
test("abc<def");
test("abc&&def");
test("abc]]>]]>def");
string str = "\x9\xa\xd";
for (int i = 32; i < 256; ++i) {
str = str + (char)i;
}
test(str);
test("abc]\30]\30>def");
return 0;
} Results:
|
The code still has (at least :/) one bug. For some reason I think there's two ways to fix it. Either escape not Quite frankly, I'm beginning to think that the next time someone finds a bug in BOINC's XML code it's time to start porting the code to some XML library. |
Looks ok to me. I would suggest that if there is any other issue we back out these changes, keep the original issue for this release and then move to an XML library afterwards. |
lib: fix xml_escape(), again (cherry picked from commit 7e9d41b)
Commit ff0b8d0 (fix CDATA escaping) introduced two bugs to xml_escape():
Fixes #2809