Skip to content

Commit a27cc29

Browse files
Address feedback: allowing pure alphanumeric titles
1 parent c5cc555 commit a27cc29

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/zimwriterfs/zimcreatorfs.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,16 @@ struct GumboOutputDestructor {
266266

267267
inline bool isValidTitle(const std::string& title, size_t min_length)
268268
{
269-
static const std::regex numeric_regex("[0-9]+");
270269
static const std::regex alphanumeric_regex("[a-zA-Z0-9]");
271270

272271
/* 1. Ensure the title has at least 3 characters */
273272
bool isLongEnough = title.length() >= min_length;
274273

275-
/* 2. Ensure the title is not only numeric */
276-
bool isNotNumeric = !std::regex_match(title, numeric_regex);
277-
278-
/* 3. Ensure the title contains at least one alphanumeric character
274+
/* 2. Ensure the title contains at least one alphanumeric character
279275
* (not all special chars) */
280276
bool hasAlphanumeric = std::regex_search(title, alphanumeric_regex);
281277

282-
return isLongEnough && isNotNumeric && hasAlphanumeric;
278+
return isLongEnough && hasAlphanumeric;
283279
}
284280

285281
std::string ZimCreatorFS::parseAndAdaptHtml(std::string& data,

test/zimwriterfs-zimcreatorfs.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ TEST(ZimCreatorFSTest, ValidateTitle)
179179

180180
EXPECT_FALSE(isValidTitle("ab", 3));
181181

182-
EXPECT_FALSE(isValidTitle("1234", 3));
183-
184182
EXPECT_TRUE(isValidTitle("Title123", 3));
185183

186184
EXPECT_TRUE(isValidTitle("Title!@#", 3));

0 commit comments

Comments
 (0)