Commit 81671bc5 authored by catch's avatar catch
Browse files

Issue #3445072 by longwave, Anybody: Improve "The libraries to include are...

Issue #3445072 by longwave, Anybody: Improve "The libraries to include are encoded incorrectly" check and message

(cherry picked from commit 803c9429)
(cherry picked from commit 186b5722)
(cherry picked from commit fb257090)
parent 4ae1e42b
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -162,10 +162,11 @@ public function deliver(Request $request, string $file_name) {
    $attached_assets = new AttachedAssets();
    $include_libraries = explode(',', UrlHelper::uncompressQueryParameter($request->query->get('include')));

    // Check that library names are in the correct format.
    $validate = function ($libraries_to_check) {
      foreach ($libraries_to_check as $library) {
        if (substr_count($library, '/') !== 1) {
          throw new BadRequestHttpException('The libraries to include are encoded incorrectly.');
        if (substr_count($library, '/') === 0) {
          throw new BadRequestHttpException(sprintf('The "%s" library name must include at least one slash.', $library));
        }
      }
    };