Commit 8d91d454 authored by Victor Stinner's avatar Victor Stinner

Issue #10653: Fix time.strftime() on Windows, check for invalid format strings

parent 4b779b37
......@@ -508,16 +508,16 @@ time_strftime(PyObject *self, PyObject *args)
fmt = PyBytes_AS_STRING(format);
#endif
#if defined(MS_WINDOWS) && defined(HAVE_WCSFTIME)
#if defined(MS_WINDOWS)
/* check that the format string contains only valid directives */
for(outbuf = wcschr(fmt, L'%');
for(outbuf = strchr(fmt, '%');
outbuf != NULL;
outbuf = wcschr(outbuf+2, L'%'))
outbuf = strchr(outbuf+2, '%'))
{
if (outbuf[1]=='#')
++outbuf; /* not documented by python, */
if (outbuf[1]=='\0' ||
!wcschr(L"aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
!strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
{
PyErr_SetString(PyExc_ValueError, "Invalid format string");
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment