Skip to content

Commit 8aa21f6

Browse files
committed
Merge branch 'develop'
2 parents 9f2708a + d892a35 commit 8aa21f6

21 files changed

+355
-74
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# PBO Manager change log
22

3+
# Version 1.9.0
4+
- File name sanitization enhanced when extracting a PBO
5+
- Junk filter behavior enhanced
6+
7+
# Version 1.8.0
8+
- Application performance improved
9+
310
# Version 1.7.0
411
- [Feature] The junk filter can be disabled in the `Options->Settings` menu.
512
- [Feature] The `pbo.json` can now be extracted from the user interface.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ add_definitions(-DPBOM_VERSION="${PBOM_VERSION}")
1111
add_definitions(-DPBOM_PROJECT_SITE="https://github.com/winseros/pboman3")
1212
add_definitions(-DPBOM_API_SITE="https://api.github.com/repos/winseros/pboman3")
1313

14-
set(CMAKE_CXX_STANDARD 17)
14+
set(CMAKE_CXX_STANDARD 20)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1616

1717
add_subdirectory(pbom)

pbom/commandline.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ namespace pboman3 {
66
using namespace CLI;
77
using namespace std;
88

9+
template <typename TChr>
10+
concept CharOrWChar = is_same_v<TChr, char> || is_same_v<TChr, wchar_t>;
11+
912
struct CommandLine {
1013
struct Command {
1114
Command() : command(nullptr) {
@@ -15,14 +18,14 @@ namespace pboman3 {
1518

1619
App* command;
1720

18-
bool hasBeenSet() const {
21+
[[nodiscard]] bool hasBeenSet() const {
1922
return command->parsed();
2023
}
2124

2225
virtual void configure(App* cli) = 0;
2326
};
2427

25-
template <typename TChr>
28+
template <CharOrWChar TChr>
2629
struct CommandOpen : Command {
2730
basic_string<TChr> fileName;
2831

@@ -34,7 +37,7 @@ namespace pboman3 {
3437
}
3538
};
3639

37-
template <typename TChr>
40+
template <CharOrWChar TChr>
3841
struct PackCommandBase : Command {
3942
PackCommandBase()
4043
: optOutputPath(nullptr)
@@ -66,7 +69,7 @@ namespace pboman3 {
6669
#endif
6770
};
6871

69-
template <typename TChr>
72+
template <CharOrWChar TChr>
7073
struct CommandPack : PackCommandBase<TChr> {
7174
vector<basic_string<TChr>> folders;
7275

@@ -92,7 +95,7 @@ namespace pboman3 {
9295
}
9396
};
9497

95-
template <typename TChr>
98+
template <CharOrWChar TChr>
9699
struct CommandUnpack : PackCommandBase<TChr> {
97100
vector<basic_string<TChr>> files;
98101

@@ -116,7 +119,7 @@ namespace pboman3 {
116119
}
117120
};
118121

119-
template <typename TChr>
122+
template <CharOrWChar TChr>
120123
struct Result {
121124
#ifdef PBOM_GUI
122125
CommandOpen<TChr> open;
@@ -131,7 +134,7 @@ namespace pboman3 {
131134
: app_(app) {
132135
}
133136

134-
template <typename TChr>
137+
template <CharOrWChar TChr>
135138
shared_ptr<Result<TChr>> build() const {
136139
auto result = make_shared<Result<TChr>>();
137140
#ifdef PBOM_GUI
@@ -143,12 +146,12 @@ namespace pboman3 {
143146
return result;
144147
}
145148

146-
template <typename TChr>
149+
template <CharOrWChar TChr>
147150
static QString toQt(const basic_string<TChr>& str) {
148151
return QString::fromStdString(str);
149152
}
150153

151-
template <typename TChr>
154+
template <CharOrWChar TChr>
152155
static QStringList toQt(const vector<basic_string<TChr>>& items) {
153156
QStringList qtItems;
154157
qtItems.reserve(static_cast<qsizetype>(items.size()));

pbom/console.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace pboman3 {
3636
return 0;
3737
}
3838

39-
template <typename TChr>
39+
template <CharOrWChar TChr>
4040
int RunWithCliOptions(int argc, TChr* argv[]) {
4141
using namespace CLI;
4242
using namespace pboman3;
@@ -73,7 +73,7 @@ namespace pboman3 {
7373
return exitCode;
7474
}
7575

76-
template <typename TChr>
76+
template <CharOrWChar TChr>
7777
int RunMain(int argc, TChr* argv[]) {
7878
const int exitCode = RunWithCliOptions(argc, argv);
7979
return exitCode;

pbom/domain/abstractnode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace pboman3::domain {
88
template <typename T>
99
class AbstractNode : public QObject {
1010
public:
11-
AbstractNode(T* parentNode)
11+
explicit AbstractNode(T* parentNode)
1212
: parentNode_(parentNode) {
1313
}
1414

@@ -20,7 +20,7 @@ namespace pboman3::domain {
2020
return childList_.at(index).get();
2121
}
2222

23-
int depth() const {
23+
[[nodiscard]] int depth() const {
2424
int result = 0;
2525
T* parentNode = parentNode_;
2626
while (parentNode) {
@@ -30,7 +30,7 @@ namespace pboman3::domain {
3030
return result;
3131
}
3232

33-
qsizetype count() const {
33+
[[nodiscard]] qsizetype count() const {
3434
return childList_.size();
3535
}
3636

pbom/io/bb/__test__/nodefilesystem_test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace pboman3::io::test {
1212
const PboNode* file = root.createHierarchy(PboPath("e1\t/e2\t/e3\t.txt"));
1313

1414
const QString path = fs.allocatePath(file);
15-
const QString expected = dir.path() + "/e1%09/e2%09/e3%09.txt";
15+
const QString expected = dir.path() + "/e1%9/e2%9/e3%9.txt";
1616

1717
ASSERT_EQ(expected, path);
1818

@@ -29,7 +29,7 @@ namespace pboman3::io::test {
2929
const PboNode* file = f1.createHierarchy(PboPath("e1\t/e2\t/e3\t.txt"));
3030

3131
const QString path = fs.allocatePath(&f1, file);
32-
const QString expected = dir.path() + "/e1%09/e2%09/e3%09.txt";
32+
const QString expected = dir.path() + "/e1%9/e2%9/e3%9.txt";
3333

3434
ASSERT_EQ(expected, path);
3535

@@ -55,8 +55,8 @@ namespace pboman3::io::test {
5555
const PboNode* file = root.createHierarchy(PboPath("e1\t/e2\t/e3\t.txt"));
5656

5757
const QString path = fs.composeAbsolutePath(file);
58-
const QString expected = dir.path() + QDir::separator() + "e1%09" + QDir::separator() + "e2%09" + QDir::separator() +
59-
"e3%09.txt";
58+
const QString expected = dir.path() + QDir::separator() + "e1%9" + QDir::separator() + "e2%9" + QDir::separator() +
59+
"e3%9.txt";
6060

6161
ASSERT_EQ(expected, path);
6262

@@ -72,7 +72,7 @@ namespace pboman3::io::test {
7272
const PboNode* file = root.createHierarchy(PboPath("e1\t/e2\t/e3\t.txt"));
7373

7474
const QString path = fs.composeRelativePath(file);
75-
const QString expected = QString("e1%09") + QDir::separator() + "e2%09" + QDir::separator() + "e3%09.txt";
75+
const QString expected = QString("e1%9") + QDir::separator() + "e2%9" + QDir::separator() + "e3%9.txt";
7676

7777
ASSERT_EQ(expected, path);
7878
}
Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,61 @@
11
#include "io/bb/sanitizedstring.h"
22
#include <QString>
3+
#include <QRegularExpression>
34
#include <gtest/gtest.h>
45

56
namespace pboman3::io::test {
6-
struct CtorParam {
7+
struct SanitizedStringTestParam {
78
const QString sourceText;
8-
const QString expectedText;
9+
const QString expectedTextOrPattern;
910
};
1011

11-
class CtorTest : public testing::TestWithParam<CtorParam> {
12+
class SanitizedStringRestrictedCharactersTest : public testing::TestWithParam<SanitizedStringTestParam> {
1213
};
1314

14-
TEST_P(CtorTest, Deals_With_Restricted_Characters) {
15+
TEST_P(SanitizedStringRestrictedCharactersTest, Deals_With_Restricted_Characters) {
1516
SanitizedString ss(GetParam().sourceText);
16-
ASSERT_EQ(static_cast<QString>(ss), GetParam().expectedText);
17+
ASSERT_EQ(static_cast<QString>(ss), GetParam().expectedTextOrPattern);
1718
}
1819

19-
INSTANTIATE_TEST_SUITE_P(SanitizedStringTest, CtorTest, testing::Values(
20-
CtorParam{"\t1\t", "%091%09"},
21-
CtorParam{"?1?", "%3F1%3F"},
22-
CtorParam{"*1*", "%2A1%2A"},
23-
CtorParam{"1///", "1%2F%2F%2F"},
24-
CtorParam{"\\2", "%5C2"}
25-
));
20+
INSTANTIATE_TEST_SUITE_P(TestSuite, SanitizedStringRestrictedCharactersTest, testing::Values(
21+
SanitizedStringTestParam{"\t1\t", "%91%9"},
22+
SanitizedStringTestParam{"?1?", "%3f1%3f"},
23+
SanitizedStringTestParam{"*1*", "%2a1%2a"},
24+
SanitizedStringTestParam{"1///", "1%2f%2f%2f"},
25+
SanitizedStringTestParam{"\\2", "%5c2"},
26+
SanitizedStringTestParam{" ", "%20%20%20%20"},
27+
SanitizedStringTestParam{"1111.", "1111%2e"},
28+
SanitizedStringTestParam{"1111 ", "1111%20"}
29+
));
30+
31+
class SanitizedStringRestrictedKeywordsTest : public testing::TestWithParam<SanitizedStringTestParam> {
32+
};
33+
34+
TEST_P(SanitizedStringRestrictedKeywordsTest, Deals_With_Restricted_Keywords) {
35+
SanitizedString ss(GetParam().sourceText);
36+
QRegularExpression re(GetParam().expectedTextOrPattern);
37+
const QRegularExpressionMatch match = re.match(static_cast<QString>(ss));
38+
ASSERT_TRUE(match.hasMatch());
39+
}
40+
41+
INSTANTIATE_TEST_SUITE_P(TestSuite, SanitizedStringRestrictedKeywordsTest, testing::Values(
42+
SanitizedStringTestParam{"COM1.c", "^COM1-\\d{1,4}.c"},
43+
SanitizedStringTestParam{"COn", "^COn-\\d{1,4}"},
44+
SanitizedStringTestParam{"COM1", "^COM1-\\d{1,4}"},
45+
SanitizedStringTestParam{"lPt2", "^lPt2-\\d{1,4}"},
46+
SanitizedStringTestParam{"NUL", "^NUL-\\d{1,4}"}
47+
));
48+
49+
class SanitizedStringLengthTest : public testing::TestWithParam<SanitizedStringTestParam> {
50+
};
51+
52+
TEST_P(SanitizedStringLengthTest, Deals_With_Long_Strings) {
53+
SanitizedString ss(GetParam().sourceText, 50);
54+
ASSERT_EQ(static_cast<QString>(ss), GetParam().expectedTextOrPattern);
55+
}
56+
57+
INSTANTIATE_TEST_SUITE_P(TestSuite, SanitizedStringLengthTest, testing::Values(
58+
SanitizedStringTestParam{"123456789a123456789a123456789a123456789a123456789ab",
59+
"123456789a1234-d642eb4f7beba2ee9fda95f3ed39de8~37"}
60+
));
2661
}

0 commit comments

Comments
 (0)