Skip to content

Commit

Permalink
Issue 75: Use is_numeric instead of preg_match().
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Jan 8, 2025
1 parent 15dad30 commit 2d0896c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Access/WopiProofAccessCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ protected function doCheckAccess(Request $request): AccessResult {
*/
protected function checkTimeout(Request $request): AccessResult {
$wopi_ticks_str = $request->headers->get('X-WOPI-Timestamp', '');
// Unfortunately, is_numeric() confuses the IDE's static analysis, so use
// regular expression instead.
if (!preg_match('#^[1-9]\d+$#', $wopi_ticks_str)) {
if (!is_numeric($wopi_ticks_str)) {
return AccessResult::forbidden('The X-WOPI-Timestamp header is missing, empty or invalid.');
}
$wopi_timestamp = DotNetTime::ticksToTimestamp((float) $wopi_ticks_str);
Expand Down

0 comments on commit 2d0896c

Please sign in to comment.