Skip to content

Commit

Permalink
Remove bad chars from filename - prevents S3 error
Browse files Browse the repository at this point in the history
Remove bad chars from filename - prevents S3 error
  • Loading branch information
wilson1000-MoJ authored May 19, 2020
2 parents 41f785c + 869967f commit df36b85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions component/Security/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ public function __construct()
global $mojHelper;
$this->helper = $mojHelper;

$this->actions();
$this->hooks();
$this->vulndb();
}

public function actions()
public function hooks()
{
// add_action('admin_enqueue_scripts', [$this, 'enqueue']);
}

public function enqueue()
{
// wp_enqueue_style('security_admin_css', $this->helper->cssPath(__FILE__) . 'main.css', []);
add_filter('sanitize_file_name', [$this, 'removeFilenameBadChars'], 10);
}

public static function vulndb()
{
return new VulnerabilityDB();
}

public static function removeFilenameBadChars($filename) {

$bad_chars = array( '', '#', '~', '%', '|', '^', '>', '<', '['. ']', '{', '}');
$filename = str_replace($bad_chars, "-", $filename);
return $filename;

}

}
2 changes: 1 addition & 1 deletion wp-moj-components.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin name: WP MoJ Components
* Plugin URI: https://github.com/ministryofjustice/wp-moj-components
* Description: Introduces various functions that are commonly used across the MoJ network of sites
* Version: 3.1.1
* Version: 3.1.2
* Author: Ministry of Justice
* Text domain: wp-moj-components
* Author URI: https://peoplefinder.service.gov.uk/people/damien-wilson
Expand Down

0 comments on commit df36b85

Please sign in to comment.