Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/controller/PhabricatorFileDataController.php
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$end = null; | $end = null; | ||||
// NOTE: It's important to accept "Range" requests when playing audio. | // NOTE: It's important to accept "Range" requests when playing audio. | ||||
// If we don't, Safari has difficulty figuring out how long sounds are | // If we don't, Safari has difficulty figuring out how long sounds are | ||||
// and glitches when trying to loop them. In particular, Safari sends | // and glitches when trying to loop them. In particular, Safari sends | ||||
// an initial request for bytes 0-1 of the audio file, and things go south | // an initial request for bytes 0-1 of the audio file, and things go south | ||||
// if we can't respond with a 206 Partial Content. | // if we can't respond with a 206 Partial Content. | ||||
$range = $request->getHTTPHeader('range'); | $range = $request->getHTTPHeader('range'); | ||||
if (strlen($range)) { | if (phutil_nonempty_string($range)) { | ||||
valerio.bozzolan: ✅ The HTTP range assumes string values like `"bytes=0-"` etc. and null but not other things. | |||||
list($begin, $end) = $response->parseHTTPRange($range); | list($begin, $end) = $response->parseHTTPRange($range); | ||||
} | } | ||||
if (!$file->isViewableInBrowser()) { | if (!$file->isViewableInBrowser()) { | ||||
$is_download = true; | $is_download = true; | ||||
} | } | ||||
$request_type = $request->getHTTPHeader('X-Phabricator-Request-Type'); | $request_type = $request->getHTTPHeader('X-Phabricator-Request-Type'); | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
✅ The HTTP range assumes string values like "bytes=0-" etc. and null but not other things.
The phutil_nonempty_string() will report alien values and that is OK.