DevToys-app / DevToys

A Swiss Army knife for developers.
https://devtoys.app/
MIT License
26.68k stars 1.42k forks source link

Error in Cron parser #642

Open PixelsIng opened 2 years ago

PixelsIng commented 2 years ago

Description

A cron "formula" of this kind 0 1 2-8 * 0 is interpreted as : The sunday at 1:00 if the day is between 2 and 8, giving => Next dates : 2022-09-04 dim. 01:00:00 2022-10-02 dim. 01:00:00 2022-11-06 dim. 01:00:00 2022-12-04 dim. 01:00:00 2023-01-08 dim. 01:00:00 2023-02-05 dim. 01:00:00 2023-03-05 dim. 01:00:00

Steps To Reproduce

No response

Expected behavior

In reality, Linux (tested on Ubuntu 20.04 LTS) parses this formula as : At 1:00, each day between 2 and 8 AND each sunday

DevToys Version

Version 1.0.9.0 | X64 | RELEASE | 8bcfa60 | 8bcfa60

Relevant Assets/Logs

- [08/25/2022 10:24:30]

Feature name: SmartDetection - Check if tool is recommended Custom message: Tool : Xml Validator Exception message: Data at the root level is invalid. Line 1, position 1. Exception stack trace: at System.Xml.XmlTextReaderImpl.Throw(Exception) + 0x6c at System.Xml.XmlTextReaderImpl.Throw(String, String) + 0x56 at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() + 0x1a5 at System.Xml.XmlTextReaderImpl.ParseDocumentContent() + 0x22d at System.Xml.XmlTextReaderImpl.Read() + 0x355 at System.Xml.XmlTextReader.Read() + 0xf at System.Xml.Schema.Parser.StartParsing(XmlReader, String) + 0xb7 at System.Xml.Schema.Parser.Parse(XmlReader, String) + 0x10 at System.Xml.Schema.XmlSchema.Read(XmlReader, ValidationEventHandler) + 0x86 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.ValidateXsdData(String) + 0x122 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.CanBeTreatedByTool(String) + 0x18 at DevToys.Api.Tools.ToolProviderViewItem.d40.MoveNext() + 0xc0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17 at System.Runtime.CompilerServices.TaskAwaiter.GetResult() + 0xb at DevToys.ViewModels.MainPageViewModel.<>cDisplayClass88_1.<b__2>d.MoveNext() + 0x107

- [08/25/2022 10:44:20]

Feature name: SmartDetection - Check if tool is recommended Custom message: Tool : Xml Validator Exception message: Data at the root level is invalid. Line 1, position 1. Exception stack trace: at System.Xml.XmlTextReaderImpl.Throw(Exception) + 0x6c at System.Xml.XmlTextReaderImpl.Throw(String, String) + 0x56 at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() + 0x1a5 at System.Xml.XmlTextReaderImpl.ParseDocumentContent() + 0x22d at System.Xml.XmlTextReaderImpl.Read() + 0x355 at System.Xml.XmlTextReader.Read() + 0xf at System.Xml.Schema.Parser.StartParsing(XmlReader, String) + 0xb7 at System.Xml.Schema.Parser.Parse(XmlReader, String) + 0x10 at System.Xml.Schema.XmlSchema.Read(XmlReader, ValidationEventHandler) + 0x86 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.ValidateXsdData(String) + 0x122 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.CanBeTreatedByTool(String) + 0x18 at DevToys.Api.Tools.ToolProviderViewItem.d40.MoveNext() + 0xc0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17 at System.Runtime.CompilerServices.TaskAwaiter.GetResult() + 0xb at DevToys.ViewModels.MainPageViewModel.<>cDisplayClass88_1.<b__2>d.MoveNext() + 0x107

- [08/25/2022 10:46:45]

Feature name: SmartDetection - Check if tool is recommended Custom message: Tool : Xml Validator Exception message: Data at the root level is invalid. Line 1, position 1. Exception stack trace: at System.Xml.XmlTextReaderImpl.Throw(Exception) + 0x6c at System.Xml.XmlTextReaderImpl.Throw(String, String) + 0x56 at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() + 0x1a5 at System.Xml.XmlTextReaderImpl.ParseDocumentContent() + 0x22d at System.Xml.XmlTextReaderImpl.Read() + 0x355 at System.Xml.XmlTextReader.Read() + 0xf at System.Xml.Schema.Parser.StartParsing(XmlReader, String) + 0xb7 at System.Xml.Schema.Parser.Parse(XmlReader, String) + 0x10 at System.Xml.Schema.XmlSchema.Read(XmlReader, ValidationEventHandler) + 0x86 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.ValidateXsdData(String) + 0x122 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.CanBeTreatedByTool(String) + 0x18 at DevToys.Api.Tools.ToolProviderViewItem.d40.MoveNext() + 0xc0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17 at System.Runtime.CompilerServices.TaskAwaiter.GetResult() + 0xb at DevToys.ViewModels.MainPageViewModel.<>cDisplayClass88_1.<b__2>d.MoveNext() + 0x107

- [08/25/2022 10:52:05]

Feature name: SmartDetection - Check if tool is recommended Custom message: Tool : Xml Validator Exception message: Data at the root level is invalid. Line 1, position 1. Exception stack trace: at System.Xml.XmlTextReaderImpl.Throw(Exception) + 0x6c at System.Xml.XmlTextReaderImpl.Throw(String, String) + 0x56 at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() + 0x1a5 at System.Xml.XmlTextReaderImpl.ParseDocumentContent() + 0x22d at System.Xml.XmlTextReaderImpl.Read() + 0x355 at System.Xml.XmlTextReader.Read() + 0xf at System.Xml.Schema.Parser.StartParsing(XmlReader, String) + 0xb7 at System.Xml.Schema.Parser.Parse(XmlReader, String) + 0x10 at System.Xml.Schema.XmlSchema.Read(XmlReader, ValidationEventHandler) + 0x86 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.ValidateXsdData(String) + 0x122 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.CanBeTreatedByTool(String) + 0x18 at DevToys.Api.Tools.ToolProviderViewItem.d40.MoveNext() + 0xc0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17 at System.Runtime.CompilerServices.TaskAwaiter.GetResult() + 0xb at DevToys.ViewModels.MainPageViewModel.<>cDisplayClass88_1.<b__2>d.MoveNext() + 0x107

- [08/25/2022 10:52:19]

Feature name: SmartDetection - Check if tool is recommended Custom message: Tool : Xml Validator Exception message: Data at the root level is invalid. Line 1, position 1. Exception stack trace: at System.Xml.XmlTextReaderImpl.Throw(Exception) + 0x6c at System.Xml.XmlTextReaderImpl.Throw(String, String) + 0x56 at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() + 0x1a5 at System.Xml.XmlTextReaderImpl.ParseDocumentContent() + 0x22d at System.Xml.XmlTextReaderImpl.Read() + 0x355 at System.Xml.XmlTextReader.Read() + 0xf at System.Xml.Schema.Parser.StartParsing(XmlReader, String) + 0xb7 at System.Xml.Schema.Parser.Parse(XmlReader, String) + 0x10 at System.Xml.Schema.XmlSchema.Read(XmlReader, ValidationEventHandler) + 0x86 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.ValidateXsdData(String) + 0x122 at DevToys.ViewModels.Tools.XmlValidator.XmlValidatorToolProvider.CanBeTreatedByTool(String) + 0x18 at DevToys.Api.Tools.ToolProviderViewItem.d40.MoveNext() + 0xc0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17 at System.Runtime.CompilerServices.TaskAwaiter.GetResult() + 0xb at DevToys.ViewModels.MainPageViewModel.<>cDisplayClass88_1.<b__2>d.MoveNext() + 0x107

jamescurran commented 2 years ago

I was quite surprised that the "Expected Behavior" given above is actually correct. The specification for cron does cite that as a special case:

Finally, if either the month or day of month is specified as an element or list, and the day of week is also specified as an element or list, then any day matching either the month and day of month, or the day of week, shall be matched.

https://pubs.opengroup.org/onlinepubs/007904975/utilities/crontab.html

(It's very hard to find any example on the Internet where both the day-of-month and day-of-week are non-wildcards.)

jamescurran commented 2 years ago

However, it appears the actual parsing and interpretation is done by the Nuget package Cronos (https://github.com/HangfireIO/Cronos) so the bug really should be posted there.