Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

video "source" elements have inappropriate mime-types #131

Open
mozai opened this issue Mar 16, 2021 · 0 comments
Open

video "source" elements have inappropriate mime-types #131

mozai opened this issue Mar 16, 2021 · 0 comments

Comments

@mozai
Copy link

mozai commented Mar 16, 2021

forum/Sources/Subs.php, lines 1629-1635:

+   +   +   +   +   +   $tag['content'] = "-
+   +   +   +   +   +   <video width='768' height='auto' style='max-width: 100%' controls>-
+   +   +   +   +   +   <source src='{$data}' type='video/mp4'>-
+   +   +   +   +   +   <source src='{$data}' type='video/webm'>-
+   +   +   +   +   +   <source src='{$data}' type='video/ogg'>-
+   +   +   +   +   +   Your browser does not support the video tag.-
+   +   +   +   +   +   </video>";-

Same source with multiple mime-types confuses web browsers, and a webbrowser could pick the last for an MPEG4 file, or the first for an Ogg Vorbis file.

Maybe try

$minortype = pathinfo($data, PATHINFO_EXTENSION);
$minortype = ($minortype == "ogv") ? "ogg" : $minortype;
$tag['content'] = "<video width='768' height='auto' style='max-width: 100%' controls>
<source src='{$data}' type='video/{$minortype}'/>Your browser does not support the video tag</video>
"

Using the filename to detect the mime-type is flimsy, but better than what's currently used. Real mime-type detecting requires downloading the first ~4kB of the file and scrutinizing the bytes, and even then it's not guaranteed (some file formats put their catalog info at the tail-end of the file... smh).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant