$sanitizer->path() method

Validate the given path, return path if valid, or false if not valid

Returns the given path if valid, or boolean false if not.

Path is validated per ProcessWire "name" convention of ascii only [-_./a-z0-9] As a result, this function is primarily useful for validating ProcessWire paths, and won't always work with paths outside ProcessWire.

This method validates only and does not sanitize. See $sanitizer->pagePathName() for a similar method that does sanitiation.

Usage

// basic usage
$bool = $sanitizer->path(string $value);

// usage with all arguments
$bool = $sanitizer->path(string $value, $options = []);

Arguments

NameType(s)Description
valuestring

Path to validate

options (optional)int, array

Options to modify behavior, or maxLength (int) may be specified.

  • allowDotDot (bool): Whether to allow ".." in a path (default=false)
  • maxLength (int): Maximum length of allowed path (default=1024)

Return value

bool string

Returns false if invalid, actual path (string) if valid.

See Also


$sanitizer methods and properties

API reference based on ProcessWire core version 3.0.172

Twitter updates

  • This week ProcessWire gained powerful new tools for finding pages and controlling how they are loaded. If you like to maximize performance and efficiency, you’ll like what 3.0.172 brings— More
    5 February 2021
  • ProcessWire 3.0.171 dev branch core updates – More
    22 January 2021
  • Preliminary 2021 roadmap in progress in this week’s update— More
    8 January 2021

Latest news

  • ProcessWire Weekly #352
    In the 352nd issue of ProcessWire Weekly we're going to check out the latest core updates available in ProcessWire 3.0.172, introduce a neat third party module called Admin Autosize Textareas, and more. Read on!
    Weekly.pw / 6 February 2021
  • ProcessWire 3.0.172 – Find faster and more efficiently
    This week ProcessWire gained powerful new tools for finding pages and controlling how they are loaded. If you like to maximize performance and efficiency, you’ll like what 3.0.172 brings.
    Blog / 5 February 2021
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK