Patterns with forward slashes cause preg_match warnings

Created on 27 June 2024, 9 months ago

Problem/Motivation

When redirect patterns are URL paths that contain slashes, hits to pages generate preg_match warnings. If there are a large number of redirects defined, this can cause the logs to fill up pretty quickly, especially when hackers keep trying to access xmlrpc.php or any number of other pages that don't exist.

Steps to reproduce

  1. Go to /admin/config/broken_link_redirect and create a redirect - use a file path that contains a / in the pattern
  2. Try to access a page that does not exist (our example was xmlrpc.php)
  3. Review the DB logs - there will be a warning about an unknown modifier from the preg_match function

Proposed resolution

Escape slashes in the pattern before calling preg_match. I have included a patch for this.

πŸ› Bug report
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cobblestone.consulting

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024