Skip to content

w2PgetParam()'s character filter never matches #403

Closed

Description

@caseysoftware

w2PgetParam() (includes/main_functions.php) tries to strip characters such as quotes, brackets and semicolons from request values:

$result = preg_replace("/<>\`'\"\[\]{}():;/", "", $_result);

The pattern isn't a character class, so it only matches that exact sequence of characters and practically never removes anything. The array branch has the same problem. In practice w2PgetParam() only runs strip_tags() on strings and does nothing to array values.

Code that relies on it to make a value safe for SQL or HTML is unprotected. It also can't be "fixed" by turning it into a character class without breaking legitimate input (names with apostrophes, URLs with colons).

Fix:

  • Remove the misleading preg_replace() calls, or document that w2PgetParam() only strips tags.
  • Audit callers that put w2PgetParam() results into SQL or HTML without a cast or escaping, and cast ((int)), quote ($q->quote()) or escape (htmlspecialchars()) them at the point of use.

Activity

  1. added a commit that references this issue on Oct 21, 2026
    e1c1cbf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions