mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Merge branch 'master' into PHRAS-2815_generate-cterms-multi-db_4.1
This commit is contained in:
@@ -63,4 +63,26 @@ class StringUtils
|
||||
|
||||
return self::$transliterator->transliterate($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* replace bad chars (ascii 0...31 except 9,10,13)
|
||||
*
|
||||
* @param $s
|
||||
* @param string $replace
|
||||
* @return mixed
|
||||
*/
|
||||
public static function substituteCtrlCharacters($s, $replace = '_')
|
||||
{
|
||||
static $bad_chars = null;
|
||||
if($bad_chars === null) {
|
||||
$bad_chars = [];
|
||||
for($i=0; $i<32; $i++) {
|
||||
if($i != 9 && $i != 10 && $i != 13) {
|
||||
$bad_chars[] = chr($i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return str_replace($bad_chars, $replace, $s);
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ class CandidateTerms
|
||||
|
||||
public function insert($field, $value)
|
||||
{
|
||||
$value = StringUtils::substituteCtrlCharacters($value, '');
|
||||
$this->ensureVisitorSetup();
|
||||
if (!$this->visitor->hasTerm($field, $value)) {
|
||||
$this->new_candidates[$value] = $field;
|
||||
|
Reference in New Issue
Block a user