File: vue%2B%2B%40vue%2Bcompiler-sfc%2B2.7.16.patch

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (29 lines) | stat: -rw-r--r-- 1,450 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
diff --git a/node_modules/vue/node_modules/@vue/compiler-sfc/dist/compiler-sfc.js b/node_modules/vue/node_modules/@vue/compiler-sfc/dist/compiler-sfc.js
index 91da3e0..001cf4f 100644
--- a/node_modules/vue/node_modules/@vue/compiler-sfc/dist/compiler-sfc.js
+++ b/node_modules/vue/node_modules/@vue/compiler-sfc/dist/compiler-sfc.js
@@ -9658,7 +9658,23 @@ const splitRE = /\r?\n/g;
 const emptyRE = /^(?:\/\/)?\s*$/;
 function parse(options) {
     const { source, filename = DEFAULT_FILENAME, compiler, compilerParseOptions = { pad: false }, sourceRoot = '', needMap = true, sourceMap = needMap } = options;
-    const cacheKey = hashSum(filename + source + JSON.stringify(compilerParseOptions));
+    /**
+     * Even though it seems unlikely, with about 3400 files,
+     * there is a chance to hit a hash collision of 1.3‰.
+     * And if you have a collision under the influence of 1.3‰
+     * probability, it can end really badly.
+     *
+     * by simply hashing the parts of the hash separately,
+     * we increase the entropy quite a bit because:
+     *
+     * hash(a+b) != hash(a) + hash(b)
+     *
+     * This decreases the probability of hitting a collision
+     * 570000 times.
+     *
+     */
+    const cacheKey = hashSum(sourceRoot) + '-' + hashSum(filename) + '-' + hashSum(source) + '-' + hashSum(JSON.stringify(compilerParseOptions));
+
     let output = cache.get(cacheKey);
     if (output) {
         return output;