diff --git a/Blacklight/Binaries.php b/Blacklight/Binaries.php index 830a11226..668c50f55 100644 --- a/Blacklight/Binaries.php +++ b/Blacklight/Binaries.php @@ -786,7 +786,7 @@ class Binaries INSERT INTO collections (subject, fromname, date, xref, groups_id, totalfiles, collectionhash, collection_regexes_id, dateadded) VALUES (%s, %s, FROM_UNIXTIME(%s), %s, %d, %d, '%s', %d, NOW()) - ON DUPLICATE KEY UPDATE %s dateadded = NOW(), noise = '%s'", escapeString(substr(mb_convert_encoding($this->header['matches'][1], 'UTF-8'), 0, 255)), escapeString(mb_convert_encoding($this->header['From'], 'UTF-8')), $unixtime, escapeString(implode(' ', $tempHeaderXrefs)), $this->groupMySQL['id'], $fileCount[3], sha1($this->header['CollectionKey']), $collMatch['id'], $xref, sodium_bin2hex($random))); + ON DUPLICATE KEY UPDATE %s dateadded = NOW(), noise = '%s'", escapeString(substr(mb_convert_encoding($this->header['matches'][1], 'UTF-8', mb_list_encodings()), 0, 255)), escapeString(mb_convert_encoding($this->header['From'], 'UTF-8', mb_list_encodings())), $unixtime, escapeString(implode(' ', $tempHeaderXrefs)), $this->groupMySQL['id'], $fileCount[3], sha1($this->header['CollectionKey']), $collMatch['id'], $xref, sodium_bin2hex($random))); $collectionID = $this->_pdo->lastInsertId(); DB::commit(); } catch (\Throwable $e) { @@ -819,7 +819,7 @@ class Binaries DB::insert(sprintf(" INSERT INTO binaries (binaryhash, name, collections_id, totalparts, currentparts, filenumber, partsize) VALUES (UNHEX('%s'), %s, %d, %d, 1, %d, %d) - ON DUPLICATE KEY UPDATE currentparts = currentparts + 1, partsize = partsize + %d", $hash, escapeString(mb_convert_encoding($this->header['matches'][1], 'UTF-8')), $collectionID, $this->header['matches'][3], $fileCount[1], $this->header['Bytes'], $this->header['Bytes'])); + ON DUPLICATE KEY UPDATE currentparts = currentparts + 1, partsize = partsize + %d", $hash, escapeString(mb_convert_encoding($this->header['matches'][1], 'UTF-8', mb_list_encodings())), $collectionID, $this->header['matches'][3], $fileCount[1], $this->header['Bytes'], $this->header['Bytes'])); $binaryID = $this->_pdo->lastInsertId(); DB::commit(); } catch (\Throwable $e) { diff --git a/Blacklight/CollectionsCleaning.php b/Blacklight/CollectionsCleaning.php index e1fc1a419..d2ba8786d 100755 --- a/Blacklight/CollectionsCleaning.php +++ b/Blacklight/CollectionsCleaning.php @@ -124,7 +124,7 @@ class CollectionsCleaning // Multi spaces. return [ 'id' => self::REGEX_GENERIC_MATCH, - 'name' => mb_convert_encoding(trim(preg_replace('/\s\s+/', ' ', $cleanSubject)), 'UTF-8'), + 'name' => mb_convert_encoding(trim(preg_replace('/\s\s+/', ' ', $cleanSubject)), 'UTF-8', mb_list_encodings()), ]; } // Music groups. @@ -150,7 +150,7 @@ class CollectionsCleaning '/AutoRarPar\d{1,5}|\(\d+\)( | )yEnc|\d+(Amateur|Classic)| \d{4,}[a-z]{4,} |.vol\d+\+\d+|.part\d+/i', ], ' ', $this->subject); // Multi spaces. - $cleanSubject = mb_convert_encoding(trim(preg_replace('/\s\s+/i', ' ', $cleanSubject)), 'UTF-8'); + $cleanSubject = mb_convert_encoding(trim(preg_replace('/\s\s+/i', ' ', $cleanSubject)), 'UTF-8', mb_list_encodings()); // If the subject is too similar to another because it is so short, try to extract info from the subject. if (\strlen($cleanSubject) <= 10 || preg_match('/^[\-a-z0-9$ ]{1,7}yEnc$/i', $cleanSubject)) { $x = ''; diff --git a/Blacklight/NZBImport.php b/Blacklight/NZBImport.php index f1b5d2977..dae6353bd 100755 --- a/Blacklight/NZBImport.php +++ b/Blacklight/NZBImport.php @@ -321,7 +321,7 @@ class NZBImport } } else { if ($isBlackListed) { - $errorMessage = 'Subject is blacklisted: '.mb_convert_encoding(trim($firstName), 'UTF-8'); + $errorMessage = 'Subject is blacklisted: '.mb_convert_encoding(trim($firstName), 'UTF-8', mb_list_encodings()); } else { $errorMessage = 'No group found for '.$firstName.' (one of '.implode(', ', $groupArr).' are missing'; } @@ -371,7 +371,7 @@ class NZBImport // Remove part count from subject. $partLess = preg_replace('/(\(\d+\/\d+\))*$/', 'yEnc', $nzbDetails['subject']); // Remove added yEnc from above and anything after. - $subject = mb_convert_encoding(trim(preg_replace('/yEnc.*$/i', 'yEnc', $partLess)), 'UTF-8'); + $subject = mb_convert_encoding(trim(preg_replace('/yEnc.*$/i', 'yEnc', $partLess)), 'UTF-8', mb_list_encodings()); $renamed = 0; if ($nzbDetails['useFName']) { diff --git a/Blacklight/ReleaseCleaning.php b/Blacklight/ReleaseCleaning.php index be13da37c..623e8277b 100755 --- a/Blacklight/ReleaseCleaning.php +++ b/Blacklight/ReleaseCleaning.php @@ -444,7 +444,7 @@ class ReleaseCleaning //Replace multiple spaces with 1 space $cleanerName = preg_replace('/\s\s+/i', ' ', $cleanerName); //Remove invalid characters. - $cleanerName = trim(mb_convert_encoding(preg_replace('/[^(\x20-\x7F)]*/', '', $cleanerName), 'UTF-8')); + $cleanerName = trim(mb_convert_encoding(preg_replace('/[^(\x20-\x7F)]*/', '', $cleanerName), 'UTF-8', mb_list_encodings())); return $cleanerName; } diff --git a/Blacklight/processing/ProcessReleases.php b/Blacklight/processing/ProcessReleases.php index ba90faf09..8e4fb9f6f 100755 --- a/Blacklight/processing/ProcessReleases.php +++ b/Blacklight/processing/ProcessReleases.php @@ -424,9 +424,9 @@ class ProcessReleases } foreach ($collections as $collection) { - $cleanRelName = mb_convert_encoding(str_replace(['#', '@', '$', '%', '^', '§', '¨', '©', 'Ö'], '', $collection->subject), 'UTF-8'); + $cleanRelName = mb_convert_encoding(str_replace(['#', '@', '$', '%', '^', '§', '¨', '©', 'Ö'], '', $collection->subject), 'UTF-8', mb_list_encodings()); $fromName = mb_convert_encoding( - trim($collection->fromname, "'"), 'UTF-8' + trim($collection->fromname, "'"), 'UTF-8', mb_list_encodings() ); // Look for duplicates, duplicates match on releases.name, releases.fromname and releases.size @@ -467,7 +467,7 @@ class ProcessReleases $releaseID = Release::insertRelease( [ 'name' => $cleanRelName, - 'searchname' => ! empty($cleanedName) ? mb_convert_encoding($cleanedName, 'UTF-8') : $cleanRelName, + 'searchname' => ! empty($cleanedName) ? mb_convert_encoding($cleanedName, 'UTF-8', mb_list_encodings()) : $cleanRelName, 'totalpart' => $collection->totalfiles, 'groups_id' => $collection->groups_id, 'guid' => createGUID(),