@lark-apaas/fullstack-nestjs-core 1.1.12-alpha.5 → 1.1.12-alpha.6

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/dist/index.cjs CHANGED
@@ -172,38 +172,10 @@ var import_common3 = require("@nestjs/common");
172
172
  var import_nestjs_common = require("@lark-apaas/nestjs-common");
173
173
 
174
174
  // src/utils/safe-stringify.ts
175
- function normalEscape(s) {
176
- return s.replace(/[<>&='\u2028\u2029]/g, function(c) {
177
- switch (c.charCodeAt(0)) {
178
- case 60:
179
- return "<";
180
- // <
181
- case 62:
182
- return ">";
183
- // >
184
- case 38:
185
- return "&";
186
- // &
187
- case 61:
188
- return "=";
189
- // =
190
- case 39:
191
- return "'";
192
- // '
193
- // 正常来说用户无法输入这几个字符, 现代浏览器也修复了这个问题
194
- // https://zhuanlan.zhihu.com/p/29958439
195
- case 8232:
196
- return "\u2028";
197
- // 行分隔符
198
- case 8233:
199
- return "\u2029";
200
- // 段落分隔符
201
- default:
202
- return c;
203
- }
204
- });
175
+ function escapeRegExp(str) {
176
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
205
177
  }
206
- __name(normalEscape, "normalEscape");
178
+ __name(escapeRegExp, "escapeRegExp");
207
179
 
208
180
  // src/middlewares/view-context/index.ts
209
181
  function _ts_decorate3(decorators, target, key, desc) {
@@ -261,9 +233,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
261
233
  csrfToken: csrfToken ?? "",
262
234
  userId: userId ?? "",
263
235
  appId: appId ?? "",
264
- appName: normalEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
236
+ appName: escapeRegExp(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
265
237
  appAvatar: appInfo?.app_avatar ?? "",
266
- appDescription: normalEscape(appInfo?.app_description ?? ""),
238
+ appDescription: escapeRegExp(appInfo?.app_description ?? ""),
267
239
  tenantId
268
240
  };
269
241
  res.locals = {
@@ -272,9 +244,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
272
244
  userId: userId ?? "",
273
245
  tenantId: tenantId ?? "",
274
246
  appId: appId ?? "",
275
- appName: normalEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
247
+ appName: escapeRegExp(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
276
248
  appAvatar: appInfo?.app_avatar ?? "",
277
- appDescription: normalEscape(appInfo?.app_description ?? "")
249
+ appDescription: escapeRegExp(appInfo?.app_description ?? "")
278
250
  };
279
251
  next();
280
252
  }
package/dist/index.js CHANGED
@@ -130,38 +130,10 @@ import { Inject, Injectable as Injectable3, Logger } from "@nestjs/common";
130
130
  import { PLATFORM_HTTP_CLIENT } from "@lark-apaas/nestjs-common";
131
131
 
132
132
  // src/utils/safe-stringify.ts
133
- function normalEscape(s) {
134
- return s.replace(/[<>&='\u2028\u2029]/g, function(c) {
135
- switch (c.charCodeAt(0)) {
136
- case 60:
137
- return "<";
138
- // <
139
- case 62:
140
- return ">";
141
- // >
142
- case 38:
143
- return "&";
144
- // &
145
- case 61:
146
- return "=";
147
- // =
148
- case 39:
149
- return "'";
150
- // '
151
- // 正常来说用户无法输入这几个字符, 现代浏览器也修复了这个问题
152
- // https://zhuanlan.zhihu.com/p/29958439
153
- case 8232:
154
- return "\u2028";
155
- // 行分隔符
156
- case 8233:
157
- return "\u2029";
158
- // 段落分隔符
159
- default:
160
- return c;
161
- }
162
- });
133
+ function escapeRegExp(str) {
134
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
163
135
  }
164
- __name(normalEscape, "normalEscape");
136
+ __name(escapeRegExp, "escapeRegExp");
165
137
 
166
138
  // src/middlewares/view-context/index.ts
167
139
  function _ts_decorate3(decorators, target, key, desc) {
@@ -219,9 +191,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
219
191
  csrfToken: csrfToken ?? "",
220
192
  userId: userId ?? "",
221
193
  appId: appId ?? "",
222
- appName: normalEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
194
+ appName: escapeRegExp(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
223
195
  appAvatar: appInfo?.app_avatar ?? "",
224
- appDescription: normalEscape(appInfo?.app_description ?? ""),
196
+ appDescription: escapeRegExp(appInfo?.app_description ?? ""),
225
197
  tenantId
226
198
  };
227
199
  res.locals = {
@@ -230,9 +202,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
230
202
  userId: userId ?? "",
231
203
  tenantId: tenantId ?? "",
232
204
  appId: appId ?? "",
233
- appName: normalEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
205
+ appName: escapeRegExp(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
234
206
  appAvatar: appInfo?.app_avatar ?? "",
235
- appDescription: normalEscape(appInfo?.app_description ?? "")
207
+ appDescription: escapeRegExp(appInfo?.app_description ?? "")
236
208
  };
237
209
  next();
238
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-nestjs-core",
3
- "version": "1.1.12-alpha.5",
3
+ "version": "1.1.12-alpha.6",
4
4
  "description": "FullStack Nestjs Core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",