Verified Commit cfabdf59 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3439647 by catch: Skip query string compression if zlib extension isn't available

(cherry picked from commit 26e9f32d)
parent 9eda7251
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ public static function buildQuery(array $query, $parent = '') {
   *   The data compressed into a URL-safe string.
   */
  public static function compressQueryParameter(string $data): string {
    if (!\extension_loaded('zlib')) {
      return $data;
    }
    // Use 'base64url' encoding. Note that the '=' sign is only used for padding
    // on the right of the string, and is otherwise not part of the data.
    // @see https://datatracker.ietf.org/doc/html/rfc4648#section-5
@@ -100,6 +103,9 @@ public static function compressQueryParameter(string $data): string {
   *   The uncompressed data or FALSE on failure.
   */
  public static function uncompressQueryParameter(string $compressed): string|bool {
    if (!\extension_loaded('zlib')) {
      return $compressed;
    }
    // Because this comes from user data, suppress the PHP warning that
    // gzcompress() throws if the base64-encoded string is invalid.
    return @gzuncompress(base64_decode(str_replace(['-', '_'], ['+', '/'], $compressed)));