瀏覽代碼

fix: Escapes some keys when parsing input.

j8
damencho 3 年之前
父節點
當前提交
06ce24527e

+ 10
- 3
package-lock.json 查看文件

@@ -2595,9 +2595,9 @@
2595 2595
       "integrity": "sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ=="
2596 2596
     },
2597 2597
     "@hapi/bourne": {
2598
-      "version": "1.3.2",
2599
-      "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-1.3.2.tgz",
2600
-      "integrity": "sha512-1dVNHT76Uu5N3eJNTYcvxee+jzX4Z9lfciqRRHCU27ihbUcYi+iSc2iml5Ke1LXe1SyJCLA0+14Jh4tXJgOppA=="
2598
+      "version": "2.0.0",
2599
+      "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-2.0.0.tgz",
2600
+      "integrity": "sha512-WEezM1FWztfbzqIUbsDzFRVMxSoLy3HugVcux6KDDtTqzPsLE8NDRHfXvev66aH1i2oOKKar3/XDjbvh/OUBdg=="
2601 2601
     },
2602 2602
     "@hapi/hoek": {
2603 2603
       "version": "8.5.1",
@@ -2613,6 +2613,13 @@
2613 2613
         "@hapi/bourne": "1.x.x",
2614 2614
         "@hapi/hoek": "8.x.x",
2615 2615
         "@hapi/topo": "3.x.x"
2616
+      },
2617
+      "dependencies": {
2618
+        "@hapi/bourne": {
2619
+          "version": "1.3.2",
2620
+          "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-1.3.2.tgz",
2621
+          "integrity": "sha512-1dVNHT76Uu5N3eJNTYcvxee+jzX4Z9lfciqRRHCU27ihbUcYi+iSc2iml5Ke1LXe1SyJCLA0+14Jh4tXJgOppA=="
2622
+        }
2616 2623
       }
2617 2624
     },
2618 2625
     "@hapi/topo": {

+ 1
- 0
package.json 查看文件

@@ -32,6 +32,7 @@
32 32
     "@atlaskit/theme": "11.0.2",
33 33
     "@atlaskit/toggle": "12.0.3",
34 34
     "@atlaskit/tooltip": "17.1.2",
35
+    "@hapi/bourne": "2.0.0",
35 36
     "@jitsi/js-utils": "1.0.6",
36 37
     "@material-ui/core": "4.11.3",
37 38
     "@microsoft/microsoft-graph-client": "1.1.0",

+ 2
- 1
react/features/base/config/functions.any.js 查看文件

@@ -1,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import Bourne from '@hapi/bourne';
3 4
 import { jitsiLocalStorage } from '@jitsi/js-utils';
4 5
 import _ from 'lodash';
5 6
 
@@ -141,7 +142,7 @@ export function restoreConfig(baseURL: string): ?Object {
141 142
 
142 143
     if (config) {
143 144
         try {
144
-            return JSON.parse(config) || undefined;
145
+            return Bourne.parse(config) || undefined;
145 146
         } catch (e) {
146 147
             // Somehow incorrect data ended up in the storage. Clean it up.
147 148
             jitsiLocalStorage.removeItem(key);

+ 2
- 1
react/features/base/jitsi-local-storage/setup.web.js 查看文件

@@ -1,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import Bourne from '@hapi/bourne';
3 4
 import { jitsiLocalStorage } from '@jitsi/js-utils/jitsi-local-storage';
4 5
 
5 6
 import { browser } from '../lib-jitsi-meet';
@@ -57,7 +58,7 @@ function setupJitsiLocalStorage() {
57 58
 
58 59
     if (shouldUseHostPageLocalStorage(urlParams)) {
59 60
         try {
60
-            const localStorageContent = JSON.parse(urlParams['appData.localStorageContent']);
61
+            const localStorageContent = Bourne.parse(urlParams['appData.localStorageContent']);
61 62
 
62 63
             if (typeof localStorageContent === 'object') {
63 64
                 Object.keys(localStorageContent).forEach(key => {

+ 2
- 1
react/features/base/lib-jitsi-meet/functions.native.js 查看文件

@@ -1,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import Bourne from '@hapi/bourne';
3 4
 import { NativeModules } from 'react-native';
4 5
 
5 6
 import { loadScript } from '../util';
@@ -20,7 +21,7 @@ export async function loadConfig(url: string): Promise<Object> {
20 21
     try {
21 22
         const configTxt = await loadScript(url, 10 * 1000 /* Timeout in ms */, true /* skipeval */);
22 23
         const configJson = await JavaScriptSandbox.evaluate(`${configTxt}\nJSON.stringify(config);`);
23
-        const config = JSON.parse(configJson);
24
+        const config = Bourne.parse(configJson);
24 25
 
25 26
         if (typeof config !== 'object') {
26 27
             throw new Error('config is not an object');

+ 3
- 2
react/features/base/redux/PersistenceRegistry.js 查看文件

@@ -1,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import Bourne from '@hapi/bourne';
3 4
 import { jitsiLocalStorage } from '@jitsi/js-utils';
4 5
 import md5 from 'js-md5';
5 6
 
@@ -68,7 +69,7 @@ class PersistenceRegistry {
68 69
 
69 70
             if (persistedState) {
70 71
                 try {
71
-                    persistedState = JSON.parse(persistedState);
72
+                    persistedState = Bourne.parse(persistedState);
72 73
                 } catch (error) {
73 74
                     logger.error(
74 75
                         'Error parsing persisted state',
@@ -223,7 +224,7 @@ class PersistenceRegistry {
223 224
 
224 225
         if (persistedSubtree) {
225 226
             try {
226
-                persistedSubtree = JSON.parse(persistedSubtree);
227
+                persistedSubtree = Bourne.parse(persistedSubtree);
227 228
 
228 229
                 const filteredSubtree
229 230
                     = this._getFilteredSubtree(persistedSubtree, subtreeConfig);

+ 10
- 2
react/features/base/util/parseURLParams.js 查看文件

@@ -1,7 +1,15 @@
1 1
 /* @flow */
2 2
 
3
+import Bourne from '@hapi/bourne';
4
+
3 5
 import { reportError } from './helpers';
4 6
 
7
+/**
8
+ * A list if keys to ignore when parsing.
9
+ * @type {string[]}
10
+ */
11
+const blacklist = [ '__proto__', 'constructor', 'prototype' ];
12
+
5 13
 /**
6 14
  * Parses the query/search or fragment/hash parameters out of a specific URL and
7 15
  * returns them as a JS object.
@@ -34,7 +42,7 @@ export function parseURLParams(
34 42
         const param = part.split('=');
35 43
         const key = param[0];
36 44
 
37
-        if (!key) {
45
+        if (!key || blacklist.includes(key.split('.')[0])) {
38 46
             return;
39 47
         }
40 48
 
@@ -46,7 +54,7 @@ export function parseURLParams(
46 54
             if (!dontParse) {
47 55
                 const decoded = decodeURIComponent(value).replace(/\\&/, '&');
48 56
 
49
-                value = decoded === 'undefined' ? undefined : JSON.parse(decoded);
57
+                value = decoded === 'undefined' ? undefined : Bourne.parse(decoded);
50 58
             }
51 59
         } catch (e) {
52 60
             reportError(

+ 3
- 1
react/features/local-recording/controller/RecordingController.js 查看文件

@@ -1,5 +1,7 @@
1 1
 /* @flow */
2 2
 
3
+import Bourne from '@hapi/bourne';
4
+
3 5
 import { i18next } from '../../base/i18n';
4 6
 import logger from '../logger';
5 7
 import {
@@ -427,7 +429,7 @@ class RecordingController {
427 429
                     id: member.getId(),
428 430
                     displayName: member.getDisplayName(),
429 431
                     recordingStats:
430
-                        JSON.parse(member.getProperty(PROPERTY_STATS) || '{}'),
432
+                        Bourne.parse(member.getProperty(PROPERTY_STATS) || '{}'),
431 433
                     isSelf: false
432 434
                 };
433 435
             });

+ 2
- 1
react/features/local-recording/session/SessionManager.js 查看文件

@@ -1,5 +1,6 @@
1 1
 /* @flow */
2 2
 
3
+import Bourne from '@hapi/bourne';
3 4
 import { jitsiLocalStorage } from '@jitsi/js-utils';
4 5
 
5 6
 import logger from '../logger';
@@ -163,7 +164,7 @@ class SessionManager {
163 164
 
164 165
         if (dataStr !== null) {
165 166
             try {
166
-                const dataObject = JSON.parse(dataStr);
167
+                const dataObject = Bourne.parse(dataStr);
167 168
 
168 169
                 this._sessionsMetadata = dataObject;
169 170
             } catch (e) {

+ 2
- 1
react/features/recent-list/reducer.js 查看文件

@@ -1,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import Bourne from '@hapi/bourne';
3 4
 import { jitsiLocalStorage } from '@jitsi/js-utils';
4 5
 
5 6
 import { APP_WILL_MOUNT } from '../base/app';
@@ -125,7 +126,7 @@ function _getLegacyRecentRoomList(): Array<Object> {
125 126
 
126 127
     if (str) {
127 128
         try {
128
-            return JSON.parse(str);
129
+            return Bourne.parse(str);
129 130
         } catch (error) {
130 131
             logger.warn('Failed to parse legacy recent-room list!');
131 132
         }

+ 2
- 1
react/features/virtual-background/components/VirtualBackgroundDialog.js 查看文件

@@ -1,6 +1,7 @@
1 1
 // @flow
2 2
 /* eslint-disable react/jsx-no-bind, no-return-assign */
3 3
 import Spinner from '@atlaskit/spinner';
4
+import Bourne from '@hapi/bourne';
4 5
 import { jitsiLocalStorage } from '@jitsi/js-utils/jitsi-local-storage';
5 6
 import React, { useState, useEffect } from 'react';
6 7
 import uuid from 'uuid';
@@ -90,7 +91,7 @@ type Props = {
90 91
 function VirtualBackground({ _jitsiTrack, _selectedThumbnail, _virtualSource, dispatch, t }: Props) {
91 92
     const [ options, setOptions ] = useState({});
92 93
     const localImages = jitsiLocalStorage.getItem('virtualBackgrounds');
93
-    const [ storedImages, setStoredImages ] = useState((localImages && JSON.parse(localImages)) || []);
94
+    const [ storedImages, setStoredImages ] = useState((localImages && Bourne.parse(localImages)) || []);
94 95
     const [ loading, isloading ] = useState(false);
95 96
     const [ activeDesktopVideo ] = useState(_virtualSource?.videoType === VIDEO_TYPE.DESKTOP ? _virtualSource : null);
96 97
 

Loading…
取消
儲存