@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Omit "type" attribute from "<source />" tags in "<video>" to trick Chrome into playing them

Summary:
Fixes T13135. See PHI633. For at least some video files with legitimate MIME type "video/quicktime", Chrome can play them but refuses to if the `<source />` tag has a `type="video/quicktime"` attribute.

To trick Chrome into giving these videos the old college try, omit the "type" attribute. Chrome then tries to play the video, seems to realize it can, and we're back on track.

Since the "type" attribute is theoretically only useful to help browsers select among multiple different alternatives and we're only presenting one alternative, this seems likely safe and reasonable. Omitting "type" also validates. It's hard to be certain that this won't cause any collateral damage, but intuitively it seems like it should be safe and I wasn't able to identify any problems.

Test Plan:
- Watched a "video/quicktime" MP4 cat video in Chrome/Safari/Firefox.
- See T13135 for discussion, context, and discussion of the behavior of some smaller reproduction cases.

Reviewers: amckinley, asherkin

Reviewed By: amckinley

Maniphest Tasks: T13135

Differential Revision: https://secure.phabricator.com/D19424

+13 -1
+13 -1
src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
··· 260 260 $autoplay = null; 261 261 } 262 262 263 + if ($is_video) { 264 + // See T13135. Chrome refuses to play videos with type "video/quicktime", 265 + // even though it may actually be able to play them. The least awful fix 266 + // based on available information is to simply omit the "type" attribute 267 + // from `<source />` tags. This causes Chrome to try to play the video 268 + // and realize it can, and does not appear to produce any bad behavior in 269 + // any other browser. 270 + $mime_type = null; 271 + } else { 272 + $mime_type = $file->getMimeType(); 273 + } 274 + 263 275 return $this->newTag( 264 276 $tag, 265 277 array( ··· 274 286 'source', 275 287 array( 276 288 'src' => $file->getBestURI(), 277 - 'type' => $file->getMimeType(), 289 + 'type' => $mime_type, 278 290 ))); 279 291 } 280 292