Skip to content

Commit

Permalink
Clean up weird stuff from CrossRef etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
GlazerMann committed Mar 22, 2023
1 parent bbd1038 commit 8513cdb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Template.php
Expand Up @@ -786,6 +786,10 @@ public function blank_other_than_comments($param) : bool { // Accepts arrays of
*
*/
public function add_if_new(string $param_name, string $value, string $api = '') : bool {
// Clean up weird stuff from CrossRef etc.
$value = safe_preg_replace('~[\x{2000}-\x{200A}\x{00A0}\x{202F}\x{205F}\x{3000}]~u', ' ', $value); // Non-standard spaces
$value = safe_preg_replace('~[\t\n\r\0\x0B]~u', ' ', $value); // tabs, linefeeds, null bytes
$value = safe_preg_replace('~ +~u', ' ', $value); // multiple spaces
$value = trim($value);
$param_name = trim($param_name); // Pure paranoia
if ($value === '') {
Expand Down

0 comments on commit 8513cdb

Please sign in to comment.