8000 Use xxh128 instead of xxh3 to ensure higher entropy. · symfony/symfony@0fc0857 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fc0857

Browse files
committed
Use xxh128 instead of xxh3 to ensure higher entropy.
1 parent 2c2a03a commit 0fc0857

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/Symfony/Component/HttpFoundation/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
6.2
55
---
66

7-
* Http cache store uses the `xxh3` algorithm
7+
* Http cache store uses the `xxh128` algorithm
88

99
6.1
1010
---

src/Symfony/Component/HttpKernel/HttpCache/Store.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function write(Request $request, Response $response): string
223223
*/
224224
protected function generateContentDigest(Response $response): string
225225
{
226-
return 'en'.hash('xxh3', $response->getContent());
226+
return 'en'.hash('xxh128', $response->getContent());
227227
}
228228

229229
/**

src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testSetsTheXContentDigestResponseHeaderBeforeStoring()
9494
$entries = $this->getStoreMetadata($cacheKey);
9595
[, $res] = $entries[0];
9696

97-
$this->assertEquals('en9ec9f7918d7dfc40', $res['x-content-digest'][0]);
97+
$this->assertEquals('en6c78e0e3bd51d358d01e758642b85fb8', $res['x-content-digest'][0]);
9898
}
9999

100100
public function testDoesNotTrustXContentDigestFromUpstream()
@@ -105,8 +105,8 @@ public function testDoesNotTrustXContentDigestFromUpstream()
105105
$entries = $this->getStoreMetadata($cacheKey);
106106
[, $res] = $entries[0];
107107

108-
$this->assertEquals('en9ec9f7918d7dfc40', $res['x-content-digest'][0]);
109-
$this->assertEquals('en9ec9f7918d7dfc40', $response->headers->get('X-Content-Digest'));
108+
$this->assertEquals('en6c78e0e3bd51d358d01e758642b85fb8', $res['x-content-digest'][0]);
109+
$this->assertEquals('en6c78e0e3bd51d358d01e758642b85fb8', $response->headers->get('X-Content-Digest'));
110110
}
111111

112112
public function testWritesResponseEvenIfXContentDigestIsPresent()
@@ -198,7 +198,7 @@ public function testRestoresResponseContentFromEntityStoreWithLookup()
198198
{
199199
$this->storeSimpleEntry();
200200
$response = $this->store->lookup($this->request);
201-
$this->assertEquals($this->getStorePath('en'.hash('xxh3', 'test')), $response->getContent());
201+
$this->assertEquals($this->getStorePath('en'.hash('xxh128', 'test')), $response->getContent());
202202
}
203203

204204
public function testInvalidatesMetaAndEntityStoreEntriesWithInvalidate()
@@ -251,9 +251,9 @@ public function testStoresMultipleResponsesForEachVaryCombination()
251251
$res3 = new Response('test 3', 200, ['Vary' => 'Foo Bar']);
252252
$this->store->write($req3, $res3);
253253

254-
$this->assertEquals($this->getStorePath('en'.hash('xxh3', 'test 3')), $this->store->lookup($req3)->getContent());
255-
$this->assertEquals($this->getStorePath('en'.hash('xxh3', 'test 2')), $this->store->lookup($req2)->getContent());
256-
$this->assertEquals($this->getStorePath('en'.hash('xxh3', 'test 1')), $this->store->lookup($req1)->getContent());
254+
$this->assertEquals($this->getStorePath('en'.hash('xxh128', 'test 3')), $this->store->lookup($req3)->getContent());
255+
$this->assertEquals($this->getStorePath('en'.hash('xxh128', 'test 2')), $this->store->lookup($req2)->getContent());
256+
$this->assertEquals($this->getStorePath('en'.hash('xxh128', 'test 1')), $this->store->lookup($req1)->getContent());
257257

258258
$this->assertCount(3, $this->getStoreMetadata($key));
259259
}
@@ -263,17 +263,17 @@ public function testOverwritesNonVaryingResponseWithStore()
263263
$req1 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']);
264264
$res1 = new Response('test 1', 200, ['Vary' => 'Foo Bar']);
265265
$this->store->write($req1, $res1);
266-
$this->assertEquals($this->getStorePath('en'.hash('xxh3', 'test 1')), $this->store->lookup($req1)->getContent());
266+
$this->assertEquals($this->getStorePath('en'.hash('xxh128', 'test 1')), $this->store->lookup($req1)->getContent());
267267

268268
$req2 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam']);
269269
$res2 = new Response('test 2', 200, ['Vary' => 'Foo Bar']);
270270
$this->store->write($req2, $res2);
271-
$this->assertEquals($this->getStorePath('en'.hash('xxh3', 'test 2')), $this->store->lookup($req2)->getContent());
271+
$this->assertEquals($this->getStorePath('en'.hash('xxh128', 'test 2')), $this->store->lookup($req2)->getContent());
272272

273273
$req3 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']);
274274
$res3 = new Response('test 3', 200, ['Vary' => 'Foo Bar']);
275275
$key = $this->store->write($req3, $res3);
276-
$this->assertEquals($this->getStorePath('en'.hash('xxh3', 'test 3')), $this->store->lookup($req3)->getContent());
276+
$this->assertEquals($this->getStorePath('en'.hash('xxh128', 'test 3')), $this->store->lookup($req3)->getContent());
277277

278278
$this->assertCount(2, $this->getStoreMetadata($key));
279279
}

0 commit comments

Comments
 (0)
0