Skip to content

Commit

Permalink
Simplify bad file detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Apr 18, 2024
1 parent 494cafb commit d4062b9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 30 deletions.
28 changes: 0 additions & 28 deletions src/Code/Converters/BinaryFinder.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Code/Converters/TxtConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TxtConverter implements ConverterContract

public function canParseFileContent($file_content)
{
return self::hasText($file_content);
return self::hasText($file_content) && !Helpers::strContains($file_content, "\x00"); // not a binary file
}

public function fileContentToInternalFormat($file_content, $original_file_content)
Expand Down
1 change: 0 additions & 1 deletion src/Subtitles.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class Subtitles
['extension' => 'docx', 'format' => 'docx', 'name' => 'DOCX', 'class' => DocxReader::class],
['extension' => 'rtf', 'format' => 'rtf', 'name' => 'Rich text format', 'class' => RtfReader::class], // libraryies eather throws exception, not parses, or takes long to parse 2h file
['extension' => 'csv', 'format' => 'csv', 'name' => 'Coma Separated Values', 'class' => CsvConverter::class], // must be last from bottom
['extension' => 'bin', 'format' => 'bin', 'name' => 'Binary', 'class' => BinaryFinder::class],
['extension' => 'txt', 'format' => 'txt', 'name' => 'Plaintext', 'class' => TxtConverter::class], // must be the last one
];

Expand Down

0 comments on commit d4062b9

Please sign in to comment.