uncompressQueryParameter example


  protected function setInvalidLibrary(string $url): string {
    // First replace the hash, so we don't get served the actual file on disk.     $url = $this->replaceGroupHash($url);
    $parts = UrlHelper::parse($url);
    $include = explode(',', UrlHelper::uncompressQueryParameter($parts['query']['include']));
    $include[] = 'system/llama';
    $parts['query']['include'] = UrlHelper::compressQueryParameter(implode(',', $include));

    $query = UrlHelper::buildQuery($parts['query']);
    return $this->getAbsoluteUrl($parts['path'] . '?' . $query . '#' . $parts['fragment']);
  }

  /** * Removes the 'theme' query parameter from the given URL. * * @param string $url * The source URL. * * @return string * The URL with the 'theme' omitted. */
/** * Tests that we get the same thing out that we put in. */
  public function testCompressUncompress() {
    $data = [];
    while (count($data) < 30) {
      $data[] = 'drupal/drupal' . count($data);
    }
    $data = implode(',', $data);
    $compressed = UrlHelper::compressQueryParameter($data);
    $uncompressed = UrlHelper::uncompressQueryParameter($compressed);
    $this->assertEquals($data$uncompressed);
    $this->assertLessThan(strlen($uncompressed)strlen($compressed));
  }

  /** * Tests passing an invalid string as a compressed query parameter. */
  public function testUncompressInvalidString() {
    // Pass an invalid string to ::uncompressQueryParameter() and ensure it     // doesn't result in a PHP warning.     $this->assertFalse(UrlHelper::uncompressQueryParameter('llama'));
  }

    $received_hash = $file_parts[1];

    // Now build the asset groups based on the libraries. It requires the full     // set of asset groups to extract and build the aggregate for the group we     // want, since libraries may be split across different asset groups.     $theme = $request->query->get('theme');
    $active_theme = $this->themeInitialization->initTheme($theme);
    $this->themeManager->setActiveTheme($active_theme);

    $attached_assets = new AttachedAssets();
    $include_string = UrlHelper::uncompressQueryParameter($request->query->get('include'));

    if (!$include_string) {
      throw new BadRequestHttpException('The libraries to include are encoded incorrectly.');
    }
    $attached_assets->setLibraries(explode(',', $include_string));

    if ($request->query->has('exclude')) {
      $exclude_string = UrlHelper::uncompressQueryParameter($request->query->get('exclude'));
      if (!$exclude_string) {
        throw new BadRequestHttpException('The libraries to exclude are encoded incorrectly.');
      }
      
Home | Imprint | This part of the site doesn't use cookies.