File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Changelog
22
3+ # v1.1.2
4+ Fixes:
5+ - Usernames can contain ` \W ` characters [ PR #3 ] ( https://github.com/mintware-de/native-cron/pull/3 )
6+
37# v1.1.1
48Fixes:
59- Crontabs must end with an empty line [ PR #2 ] ( https://github.com/mintware-de/native-cron/pull/2 )
Original file line number Diff line number Diff line change 88
99class CronJobLine implements CrontabLineInterface
1010{
11- public const PATTERN_WITH_USER = '~^(?P<datetime> ' .DateTimeDefinition::PATTERN .')\s*(?P<user>\w +)\s*(?P<command>.+)$~ ' ;
11+ public const PATTERN_WITH_USER = '~^(?P<datetime> ' .DateTimeDefinition::PATTERN .')\s*(?P<user>[^\s] +)\s*(?P<command>.+)$~ ' ;
1212 public const PATTERN_WITHOUT_USER = '~^(?P<datetime> ' .DateTimeDefinition::PATTERN .')\s*(?P<command>.+)$~ ' ;
1313
1414 private bool $ includeUser ;
Original file line number Diff line number Diff line change @@ -132,6 +132,13 @@ public function testBuildAdvanced(): void
132132 self ::assertEquals ($ line , $ cronjobLine ->build ());
133133 }
134134
135+ public function testUserWithDashes (): void
136+ {
137+ $ line = '* * * * * www-data command ' ;
138+ $ cronjobLine = new CronJobLine ($ line , true );
139+ self ::assertEquals ('www-data ' , $ cronjobLine ->getUser ());
140+ }
141+
135142 private function checkEmptyValues (CronJobLine $ cronjobLine ): void
136143 {
137144 $ dateTimeDefinition = $ cronjobLine ->getDateTimeDefinition ();
You can’t perform that action at this time.
0 commit comments