yakuza0 2.22.30-beta.7 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yakuza0",
3
- "version": "2.22.30-beta.7",
3
+ "version": "2.22.30-beta.9",
4
4
  "description": "yakuza0 with nuxt",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -4,10 +4,12 @@ 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 oToStr = (obj) => {
7
+ const shtmlFilterGet = (obj, options) => {
8
8
  if (obj && typeof obj !== "string") {
9
9
  try {
10
- return JSON.stringify(obj);
10
+ const str = JSON.stringify(obj);
11
+ const filter = shtml(str, options);
12
+ return JSON.parse(filter)
11
13
  } catch (e) {
12
14
  return obj
13
15
  }
@@ -16,6 +18,18 @@ const oToStr = (obj) => {
16
18
  return obj
17
19
  }
18
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
+
19
33
  export default async (ctx, inject) => {
20
34
  const { $http, $utils, $yk } = ctx;
21
35
  const event = {
@@ -40,7 +54,7 @@ export default async (ctx, inject) => {
40
54
  [key, data] = args;
41
55
  break;
42
56
  }
43
- data = shtml(data, options);
57
+ data = shtmlFilterSet(data, options);
44
58
 
45
59
  const result = await $http.post('$/feapiv1/storage/set', {
46
60
  key,
@@ -63,7 +77,7 @@ export default async (ctx, inject) => {
63
77
  })
64
78
 
65
79
  if ($yk.security.stupid) {
66
- return shtml(oToStr(result && result.data));
80
+ return shtmlFilterGet(result && result.data, options);
67
81
  }
68
82
 
69
83
  return result && result.data
@@ -100,7 +114,7 @@ export default async (ctx, inject) => {
100
114
  break;
101
115
  }
102
116
 
103
- data = shtml(data, options);
117
+ data = shtmlFilterSet(data, options);
104
118
 
105
119
  return await req('storage/set', {
106
120
  body: {
@@ -120,7 +134,7 @@ export default async (ctx, inject) => {
120
134
  })
121
135
 
122
136
  if ($yk.security.stupid) {
123
- return shtml(oToStr(data));
137
+ return shtmlFilterGet(data, options);
124
138
  }
125
139
 
126
140
  return data;