Skip to content

Commit

Permalink
Fix validation
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Aug 20, 2023
1 parent f59edfa commit ee760ce
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/magnaluna
Submodule magnaluna updated 1 files
+6 −2 magna.php
4 changes: 2 additions & 2 deletions src/Magic.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ public static function canConvertOgg(): bool {
return self::$canConvert;
}
try {
Ogg::convert(new ReadableBuffer("\0"), new WritableBuffer);
Ogg::convert(new LocalFile(__DIR__.'/empty.wav'), new WritableBuffer);
self::$canConvert = true;
} catch (\Throwable) {
} catch (\Throwable $e) {
self::$canConvert = false;
}
return self::$canConvert;
Expand Down
13 changes: 8 additions & 5 deletions src/Ogg.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,14 @@ public static function validateOgg(LocalFile|RemoteUrl|ReadableStream $f): void
{
$ok = false;
try {
$cancel = new DeferredCancellation;
$ogg = new self($f, $cancel->getCancellation());
$ok = \in_array('MADELINE_ENCODER_V=1', $ogg->comments, true);
} catch (\Throwable) {
}
try {
$cancel = new DeferredCancellation;
$ogg = new self($f, $cancel->getCancellation());
$ok = \in_array('MADELINE_ENCODER_V=1', $ogg->comments, true);
} finally {
$cancel->cancel();
}
} catch (\Throwable) {}
if (!$ok) {
throw new AssertionError("The passed file was not generated by MadelineProto or @libtgvoipbot, please pre-convert it using @libtgvoip bot or install FFI and ffmpeg to perform realtime conversion!");
}
Expand Down
Binary file added src/empty.wav
Binary file not shown.

0 comments on commit ee760ce

Please sign in to comment.