Skip to content

Commit

Permalink
fix: Replace characters invisible by empty
Browse files Browse the repository at this point in the history
It's a short term fix. I don't know if it's an ideal solution.
  • Loading branch information
zak39 committed Nov 28, 2024
1 parent 9a02d60 commit c3607bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Files/Csv/CsvReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class CsvReader {

public function __construct(private BasicStreamInterface $file) {
$handle = $file->open();
$this->headers = fgetcsv($handle, 1000, Separator::COMMA);
$headers = fgetcsv($handle, 1000, Separator::COMMA);
$this->headers = array_map(function($header) {
return preg_replace('/[\x00-\x1F\x7F\x{200B}-\x{200D}\x{FEFF}]/u', '', trim($header));
}, $headers);
$file->close();
}

Expand Down
3 changes: 3 additions & 0 deletions lib/Files/Csv/ImportUsers/HeaderExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
class HeaderExtractor implements CsvHeaderExtractorInterface {
public static function getIndex(array $haystack, array $needles): int|bool {
$index = null;
$needles = array_map(function($needle) {
return preg_replace('/[\x00-\x1F\x7F\x{200B}-\x{200D}\x{FEFF}]/u', '', trim($needle));
}, $needles);
foreach($haystack as $key => $value) {
$index = array_search($value, $needles);
if ($index !== false) {
Expand Down

0 comments on commit c3607bc

Please sign in to comment.