Skip to content

Commit

Permalink
Continue enhancing string sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
winseros committed Jun 16, 2024
1 parent 618a930 commit bddd203
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pbom/io/bb/__test__/sanitizedstring_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace pboman3::io::test {
SanitizedStringTestParam{"COn", "^COn-\\d{1,4}"},
SanitizedStringTestParam{"COM1", "^COM1-\\d{1,4}"},
SanitizedStringTestParam{"lPt2", "^lPt2-\\d{1,4}"},
SanitizedStringTestParam{"NUL", "^NUL-\\d{1,4}"}
SanitizedStringTestParam{"NUL", "^NUL-\\d{1,4}"},
SanitizedStringTestParam{"COM6.{69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C}", "COM6-\\d{1,4}.%7b69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C%7d"}
));

class SanitizedStringLengthTest : public testing::TestWithParam<SanitizedStringTestParam> {
Expand Down
8 changes: 4 additions & 4 deletions pbom/io/bb/sanitizedstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ namespace pboman3::io {

if (qsizetype firstInvalidCharIndex; needsCharacterSanitization(sanitized, &firstInvalidCharIndex)) {
sanitized = doCharacterSanitization(sanitized, firstInvalidCharIndex);
} else if (QString keyWord; needsKeywordSanitization(sanitized, &keyWord)) {
}
if (QString keyWord; needsKeywordSanitization(sanitized, &keyWord)) {
sanitized = doKeywordSanitization(sanitized, keyWord);
} else if (needsWhitespaceSanitization(sanitized)) {
}
if (needsWhitespaceSanitization(sanitized)) {
sanitized = doWhitespaceSanitization(sanitized);
}

if (QChar ending; needsEndingSanitization(sanitized, &ending)) {
sanitized = doEndingSanitization(sanitized, ending);
}

if (needsLengthSanitization(sanitized, maxStringLength)) {
//such code should run in the beginning of the pipeline to truncate the text before the other processing
//but unescaped binary character sequences make QString to report its length incorrectly
Expand Down

0 comments on commit bddd203

Please sign in to comment.