pocoproject / poco

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
https://pocoproject.org
Other
8.05k stars 2.11k forks source link

DateTimeFormat RFC1036 Sunday name is short (should be long) #4486

Closed ericlogic closed 3 months ago

ericlogic commented 3 months ago

Describe the bug I'm using a FileChannel to record logs with property "rotation" sets to "daily". It crashed on Sunday with an error message: Invalid DateTimeString:Sunday, 10 Mar 24 07:34:50 GMT

To Reproduce

Path logPath = Path(commandPath()).parent().pushDirectory("logs");
File(logPath).createDirectories();
logPath.setFileName("purpose-service.log");
Channel::Ptr pFileChannel = new FileChannel();
pFileChannel->setProperty("path", logPath.toString());
pFileChannel->setProperty("rotation", "daily");
pFileChannel->setProperty("archive", "timestamp");
PatternFormatter::Ptr pFormatter = new PatternFormatter("%Y-%m-%dT%H:%M:%S %q [%s] %t");
FormattingChannel::Ptr pFormattingChannel = new FormattingChannel(pFormatter, pFileChannel);
Logger::root().setChannel(pFormattingChannel);

Logger::get("main").information("Application started!");

Logs

Exception thrown at 0x00007FF88D755B0C in purpose-service.exe: Microsoft C++ exception: Poco::SyntaxException at memory location 0x000000FC5912D730.
Syntax error: Invalid DateTimeString:Sunday, 10 Mar 24 07:34:50 GMT

Please add relevant environment information:

Additional context I did some research and found a regular expression in "Foundation/src/DateTimeFormat.cpp".

const std::string DateTimeFormat::RFC1036_REGEX(
    "(((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sun)), *)?"
    "\\d\\d? +"
    "((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +"
    "\\d\\d(\\d\\d)? +\\d\\d:\\d\\d(:\\d\\d)? "
    "(" TIMEZONES_REGEX_PART "|)?+"
    "(([+\\-]?\\d\\d\\d\\d)?|" TIMEZONES_REGEX_PART "|\\w)");

Should the "Sun" in this regular expression be changed to "Sunday"?