Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions php/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class Assets extends Settings_Component {
*/
public function __construct( Plugin $plugin ) {
parent::__construct( $plugin );
$this->should_sanitize_slugs = true;

$this->media = $plugin->get_component( 'media' );
$this->delivery = $plugin->get_component( 'delivery' );
Expand Down
11 changes: 10 additions & 1 deletion php/traits/trait-params.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ trait Params_Trait {
*/
public $separator = '.';

/**
* Whether to sanitize slugs.
*
* @var boolean
*/
protected $should_sanitize_slugs = false;

/**
* Sets the params recursively.
*
Expand Down Expand Up @@ -77,7 +84,6 @@ protected function set_param_array( $parts, $param, $value ) {
* @return $this
*/
public function set_param( $param, $value = null ) {

$sanitized_param = $this->sanitize_slug( $param );
$parts = explode( $this->separator, $sanitized_param );
$param = array_shift( $parts );
Expand Down Expand Up @@ -140,6 +146,9 @@ public function remove_param( $param ) {
* @return string
*/
protected function sanitize_slug( $slug ) {
if ( ! $this->should_sanitize_slugs || ! str_contains( $slug, $this->separator ) ) {
return $slug;
}

$sanitized = array_map( 'sanitize_file_name', explode( $this->separator, $slug ) );

Expand Down