yakuza0 2.22.30-beta.8 → 2.22.30-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/storage.plugin.js +18 -6
package/package.json
CHANGED
|
@@ -4,11 +4,11 @@ import {shtml} from 'yakuza1/lib/xss';
|
|
|
4
4
|
import yConf from 'yakuza0/config';
|
|
5
5
|
import {connect, req} from 'yakuza1/lib/ws';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const shtmlFilterGet = (obj, options) => {
|
|
8
8
|
if (obj && typeof obj !== "string") {
|
|
9
9
|
try {
|
|
10
10
|
const str = JSON.stringify(obj);
|
|
11
|
-
const filter = shtml(str);
|
|
11
|
+
const filter = shtml(str, options);
|
|
12
12
|
return JSON.parse(filter)
|
|
13
13
|
} catch (e) {
|
|
14
14
|
return obj
|
|
@@ -18,6 +18,18 @@ const shtmlFilter = (obj) => {
|
|
|
18
18
|
return obj
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const shtmlFilterSet = (obj, options) => {
|
|
22
|
+
if (obj && typeof obj !== "string") {
|
|
23
|
+
try {
|
|
24
|
+
obj = JSON.stringify(obj);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
return obj
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return shtml(obj, options);
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
export default async (ctx, inject) => {
|
|
22
34
|
const { $http, $utils, $yk } = ctx;
|
|
23
35
|
const event = {
|
|
@@ -42,7 +54,7 @@ export default async (ctx, inject) => {
|
|
|
42
54
|
[key, data] = args;
|
|
43
55
|
break;
|
|
44
56
|
}
|
|
45
|
-
data =
|
|
57
|
+
data = shtmlFilterSet(data, options);
|
|
46
58
|
|
|
47
59
|
const result = await $http.post('$/feapiv1/storage/set', {
|
|
48
60
|
key,
|
|
@@ -65,7 +77,7 @@ export default async (ctx, inject) => {
|
|
|
65
77
|
})
|
|
66
78
|
|
|
67
79
|
if ($yk.security.stupid) {
|
|
68
|
-
return
|
|
80
|
+
return shtmlFilterGet(result && result.data, options);
|
|
69
81
|
}
|
|
70
82
|
|
|
71
83
|
return result && result.data
|
|
@@ -102,7 +114,7 @@ export default async (ctx, inject) => {
|
|
|
102
114
|
break;
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
data =
|
|
117
|
+
data = shtmlFilterSet(data, options);
|
|
106
118
|
|
|
107
119
|
return await req('storage/set', {
|
|
108
120
|
body: {
|
|
@@ -122,7 +134,7 @@ export default async (ctx, inject) => {
|
|
|
122
134
|
})
|
|
123
135
|
|
|
124
136
|
if ($yk.security.stupid) {
|
|
125
|
-
return
|
|
137
|
+
return shtmlFilterGet(data, options);
|
|
126
138
|
}
|
|
127
139
|
|
|
128
140
|
return data;
|