File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ namespace pboman3::io::test {
22
22
SanitizedStringTestParam{" ?1?" , " %3f1%3f" },
23
23
SanitizedStringTestParam{" *1*" , " %2a1%2a" },
24
24
SanitizedStringTestParam{" 1///" , " 1%2f%2f%2f" },
25
- SanitizedStringTestParam{" \\ 2" , " %5c2" }
25
+ SanitizedStringTestParam{" \\ 2" , " %5c2" },
26
+ SanitizedStringTestParam{" " , " %20%20%20%20" }
26
27
));
27
28
28
29
class SanitizedStringRestrictedKeywordsTest : public testing ::TestWithParam<SanitizedStringTestParam> {
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ namespace pboman3::io {
14
14
sanitizedText_ = doCharacterSanitization (text, firstInvalidCharIndex);
15
15
} else if (QString keyWord; needsKeywordSanitization (text, &keyWord)) {
16
16
sanitizedText_ = doKeywordSanitization (text, keyWord);
17
+ } else if (needsWhitespaceSanitization (text)) {
18
+ sanitizedText_ = doWhitespaceSanitization (text);
17
19
} else {
18
20
sanitizedText_ = text;
19
21
}
@@ -77,6 +79,16 @@ namespace pboman3::io {
77
79
return result;
78
80
}
79
81
82
+ bool SanitizedString::needsWhitespaceSanitization (const QString& text) {
83
+ return !text.trimmed ().length ();
84
+ }
85
+
86
+ QString SanitizedString::doWhitespaceSanitization (const QString& text) {
87
+ QString result (text);
88
+ result = result.replace (' ' , " %20" );
89
+ return result;
90
+ }
91
+
80
92
bool SanitizedString::isCharLegal (const QChar& chr) {
81
93
if (chr == ' <' || chr == ' >' || chr == ' :' || chr == ' :' || chr == ' "' || chr == ' \\ ' || chr == ' /' ||
82
94
chr == ' |' || chr == ' ?' || chr == ' *' || chr == ' {' || chr == ' }' ) {
Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ namespace pboman3::io {
23
23
24
24
static QString doKeywordSanitization (const QString& text, const QString& keyword);
25
25
26
+ static bool needsWhitespaceSanitization (const QString& text);
27
+
28
+ static QString doWhitespaceSanitization (const QString& text);
29
+
26
30
static bool isCharLegal (const QChar& chr);
27
31
28
32
static QString sanitizeChar (const QChar& chr);
You can’t perform that action at this time.
0 commit comments