Skip to content

Commit

Permalink
Local Video: Widget video path does not allow Windows file path (#3461)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadzpogi committed Aug 1, 2024
1 parent 646f67e commit 65dab62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/Widget/Definition/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,23 @@ public function validate(array $properties, string $stage): Property
}
break;

case 'windowsPath':
// Ensure the path is a valid Windows file path ending in a file, not a directory
$windowsPathRegex = '/^(?P<Root>[A-Za-z]:)(?P<Relative>(?:\\\\[^<>:"\/\\\\|?*\r\n]+)+)(?P<File>\\\\[^<>:"\/\\\\|?*\r\n]+)$/';

// Check if the test value is not empty and does not match the regular expression
if (!empty($testValue)
&& !preg_match($windowsPathRegex, $testValue)
) {
// Throw an InvalidArgumentException if the test value is not a valid Windows path
throw new InvalidArgumentException(
$message ?? sprintf(__('%s must be a valid Windows path'), $this->title),
$this->id
);
}

break;

case 'interval':
if (!empty($testValue)) {
// Try to create a date interval from it
Expand Down
3 changes: 3 additions & 0 deletions modules/localvideo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
<rule>
<test type="and">
<condition type="required"></condition>
</test>
<test type="or">
<condition type="uri"></condition>
<condition type="windowsPath"></condition>
</test>
</rule>
</property>
Expand Down

0 comments on commit 65dab62

Please sign in to comment.