@nocobase/plugin-multi-app-manager 2.0.0-alpha.7 → 2.0.0-alpha.71

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.
Files changed (161) hide show
  1. package/dist/client/00b71fff3c8c7167.js +10 -0
  2. package/dist/client/Migrate.d.ts +10 -0
  3. package/dist/client/index.d.ts +1 -0
  4. package/dist/client/index.js +1 -1
  5. package/dist/client/settings/schemas/applications.d.ts +63 -1
  6. package/dist/externalVersion.js +8 -7
  7. package/dist/locale/de-DE.json +19 -7
  8. package/dist/locale/en-US.json +21 -7
  9. package/dist/locale/es-ES.json +23 -6
  10. package/dist/locale/fr-FR.json +26 -0
  11. package/dist/locale/hu-HU.json +26 -0
  12. package/dist/locale/id-ID.json +26 -0
  13. package/dist/locale/it-IT.json +19 -7
  14. package/dist/locale/ja-JP.json +18 -6
  15. package/dist/locale/ko-KR.json +22 -7
  16. package/dist/locale/nl-NL.json +24 -9
  17. package/dist/locale/pt-BR.json +23 -6
  18. package/dist/locale/ru-RU.json +26 -0
  19. package/dist/locale/tr-TR.json +26 -0
  20. package/dist/locale/uk-UA.json +26 -0
  21. package/dist/locale/vi-VN.json +26 -0
  22. package/dist/locale/zh-CN.json +17 -15
  23. package/dist/locale/zh-TW.json +26 -0
  24. package/dist/node_modules/p-queue/dist/index.d.ts +101 -0
  25. package/dist/node_modules/p-queue/dist/index.js +1 -0
  26. package/dist/node_modules/p-queue/dist/lower-bound.d.ts +1 -0
  27. package/dist/node_modules/p-queue/dist/lower-bound.js +21 -0
  28. package/dist/node_modules/p-queue/dist/options.d.ts +64 -0
  29. package/dist/node_modules/p-queue/dist/options.js +2 -0
  30. package/dist/node_modules/p-queue/dist/priority-queue.d.ts +12 -0
  31. package/dist/node_modules/p-queue/dist/priority-queue.js +32 -0
  32. package/dist/node_modules/p-queue/dist/queue.d.ts +7 -0
  33. package/dist/node_modules/p-queue/dist/queue.js +2 -0
  34. package/dist/node_modules/p-queue/license +9 -0
  35. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.d.ts +134 -0
  36. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.js +336 -0
  37. package/dist/node_modules/p-queue/node_modules/eventemitter3/package.json +56 -0
  38. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.js +340 -0
  39. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.min.js +1 -0
  40. package/dist/node_modules/p-queue/package.json +1 -0
  41. package/dist/server/adapters/legacy-adapter.d.ts +43 -0
  42. package/dist/server/adapters/legacy-adapter.js +207 -0
  43. package/dist/server/server.d.ts +7 -6
  44. package/dist/server/server.js +110 -186
  45. package/package.json +5 -2
  46. package/dist/client/bd12299af6cdc73a.js +0 -10
  47. package/dist/node_modules/mariadb/LICENSE +0 -502
  48. package/dist/node_modules/mariadb/callback.js +0 -41
  49. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
  50. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  51. package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
  52. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
  53. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
  54. package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
  55. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
  56. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  57. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
  58. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
  59. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
  60. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
  61. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
  62. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
  63. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
  64. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
  65. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  66. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  67. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
  68. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
  69. package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
  70. package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
  71. package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
  72. package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
  73. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  74. package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
  75. package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
  76. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  77. package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
  78. package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
  79. package/dist/node_modules/mariadb/lib/connection.js +0 -1460
  80. package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
  81. package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
  82. package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
  83. package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
  84. package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
  85. package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
  86. package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
  87. package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
  88. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  89. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  90. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
  91. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
  92. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
  93. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
  94. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
  95. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
  96. package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
  97. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  98. package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
  99. package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
  100. package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
  101. package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
  102. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  103. package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
  104. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  105. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
  106. package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
  107. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
  108. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
  109. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
  110. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
  111. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
  112. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
  113. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
  114. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
  115. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
  116. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
  117. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
  118. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
  119. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
  120. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
  121. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
  122. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
  123. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
  124. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
  125. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
  126. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
  127. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
  128. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
  129. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
  130. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
  131. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
  132. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
  133. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
  134. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
  135. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
  136. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
  137. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
  138. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
  139. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
  140. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
  141. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
  142. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
  143. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
  144. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
  145. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
  146. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
  147. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
  148. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
  149. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
  150. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
  151. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
  152. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
  153. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
  154. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
  155. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
  156. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
  157. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
  158. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
  159. package/dist/node_modules/mariadb/package.json +0 -1
  160. package/dist/node_modules/mariadb/promise.js +0 -34
  161. package/dist/node_modules/mariadb/types/index.d.ts +0 -870
@@ -1,1033 +0,0 @@
1
- const Errors = require('../misc/errors');
2
-
3
- const State = {
4
- Normal: 1 /* inside query */,
5
- String: 2 /* inside string */,
6
- SlashStarComment: 3 /* inside slash-star comment */,
7
- Escape: 4 /* found backslash */,
8
- EOLComment: 5 /* # comment, or // comment, or -- comment */,
9
- Backtick: 6 /* found backtick */,
10
- Placeholder: 7 /* found placeholder */
11
- };
12
-
13
- /**
14
- * Split query according to parameters (question mark).
15
- * Question mark in comment are not taken in account
16
- *
17
- * @returns {Array} query separated by parameters
18
- */
19
- module.exports.splitQuery = function (sql) {
20
- let partList = [];
21
- let state = State.Normal;
22
- let lastChar = '\0';
23
- let singleQuotes = false;
24
- let lastParameterPosition = 0;
25
- let idx = 0;
26
- let car = sql.charAt(idx++);
27
-
28
- while (car !== '') {
29
- if (
30
- state === State.Escape &&
31
- !((car === "'" && singleQuotes) || (car === '"' && !singleQuotes))
32
- ) {
33
- state = State.String;
34
- car = sql.charAt(idx++);
35
- continue;
36
- }
37
-
38
- switch (car) {
39
- case '*':
40
- if (state === State.Normal && lastChar == '/') state = State.SlashStarComment;
41
- break;
42
-
43
- case '/':
44
- if (state === State.SlashStarComment && lastChar == '*') state = State.Normal;
45
- break;
46
-
47
- case '#':
48
- if (state === State.Normal) state = State.EOLComment;
49
- break;
50
-
51
- case '-':
52
- if (state === State.Normal && lastChar == '-') {
53
- state = State.EOLComment;
54
- }
55
- break;
56
-
57
- case '\n':
58
- if (state === State.EOLComment) {
59
- state = State.Normal;
60
- }
61
- break;
62
-
63
- case '"':
64
- if (state === State.Normal) {
65
- state = State.String;
66
- singleQuotes = false;
67
- } else if (state === State.String && !singleQuotes) {
68
- state = State.Normal;
69
- } else if (state === State.Escape && !singleQuotes) {
70
- state = State.String;
71
- }
72
- break;
73
-
74
- case "'":
75
- if (state === State.Normal) {
76
- state = State.String;
77
- singleQuotes = true;
78
- } else if (state === State.String && singleQuotes) {
79
- state = State.Normal;
80
- } else if (state === State.Escape && singleQuotes) {
81
- state = State.String;
82
- }
83
- break;
84
-
85
- case '\\':
86
- if (state === State.String) state = State.Escape;
87
- break;
88
-
89
- case '?':
90
- if (state === State.Normal) {
91
- partList.push(sql.substring(lastParameterPosition, idx - 1));
92
- lastParameterPosition = idx;
93
- }
94
- break;
95
- case '`':
96
- if (state === State.Backtick) {
97
- state = State.Normal;
98
- } else if (state === State.Normal) {
99
- state = State.Backtick;
100
- }
101
- break;
102
- }
103
- lastChar = car;
104
-
105
- car = sql.charAt(idx++);
106
- }
107
- if (lastParameterPosition === 0) {
108
- partList.push(sql);
109
- } else {
110
- partList.push(sql.substring(lastParameterPosition));
111
- }
112
-
113
- return partList;
114
- };
115
-
116
- /**
117
- * Split query according to parameters using placeholder.
118
- *
119
- * @param sql sql with placeholders
120
- * @param info connection information
121
- * @param initialValues placeholder object
122
- * @param displaySql display sql function
123
- * @returns {{parts: Array, values: Array}}
124
- */
125
- module.exports.splitQueryPlaceholder = function (sql, info, initialValues, displaySql) {
126
- let partList = [];
127
- let values = [];
128
- let state = State.Normal;
129
- let lastChar = '\0';
130
-
131
- let singleQuotes = false;
132
- let lastParameterPosition = 0;
133
-
134
- let idx = 0;
135
- let car = sql.charAt(idx++);
136
- let placeholderName;
137
-
138
- while (car !== '') {
139
- if (
140
- state === State.Escape &&
141
- !((car === "'" && singleQuotes) || (car === '"' && !singleQuotes))
142
- ) {
143
- state = State.String;
144
- car = sql.charAt(idx++);
145
- continue;
146
- }
147
-
148
- switch (car) {
149
- case '*':
150
- if (state === State.Normal && lastChar == '/') state = State.SlashStarComment;
151
- break;
152
-
153
- case '/':
154
- if (state === State.SlashStarComment && lastChar == '*') state = State.Normal;
155
- break;
156
-
157
- case '#':
158
- if (state === State.Normal) state = State.EOLComment;
159
- break;
160
-
161
- case '-':
162
- if (state === State.Normal && lastChar == '-') {
163
- state = State.EOLComment;
164
- }
165
- break;
166
-
167
- case '\n':
168
- if (state === State.EOLComment) {
169
- state = State.Normal;
170
- }
171
- break;
172
-
173
- case '"':
174
- if (state === State.Normal) {
175
- state = State.String;
176
- singleQuotes = false;
177
- } else if (state === State.String && !singleQuotes) {
178
- state = State.Normal;
179
- } else if (state === State.Escape && !singleQuotes) {
180
- state = State.String;
181
- }
182
- break;
183
-
184
- case "'":
185
- if (state === State.Normal) {
186
- state = State.String;
187
- singleQuotes = true;
188
- } else if (state === State.String && singleQuotes) {
189
- state = State.Normal;
190
- singleQuotes = false;
191
- } else if (state === State.Escape && singleQuotes) {
192
- state = State.String;
193
- }
194
- break;
195
-
196
- case '\\':
197
- if (state === State.String) state = State.Escape;
198
- break;
199
-
200
- case ':':
201
- if (state === State.Normal) {
202
- partList.push(sql.substring(lastParameterPosition, idx - 1));
203
- placeholderName = '';
204
- while (
205
- ((car = sql.charAt(idx++)) !== '' && car >= '0' && car <= '9') ||
206
- (car >= 'A' && car <= 'Z') ||
207
- (car >= 'a' && car <= 'z') ||
208
- car === '-' ||
209
- car === '_'
210
- ) {
211
- placeholderName += car;
212
- }
213
- idx--;
214
- const val = initialValues[placeholderName];
215
- if (val === undefined) {
216
- throw Errors.createError(
217
- "Placeholder '" + placeholderName + "' is not defined",
218
- displaySql.call(),
219
- false,
220
- info,
221
- 'HY000',
222
- Errors.ER_PLACEHOLDER_UNDEFINED
223
- );
224
- }
225
- values.push(val);
226
- lastParameterPosition = idx;
227
- }
228
- break;
229
- case '`':
230
- if (state === State.Backtick) {
231
- state = State.Normal;
232
- } else if (state === State.Normal) {
233
- state = State.Backtick;
234
- }
235
- }
236
- lastChar = car;
237
-
238
- car = sql.charAt(idx++);
239
- }
240
- if (lastParameterPosition === 0) {
241
- partList.push(sql);
242
- } else {
243
- partList.push(sql.substring(lastParameterPosition));
244
- }
245
-
246
- return { parts: partList, values: values };
247
- };
248
-
249
- /**
250
- * Split query according to parameters (question mark).
251
- *
252
- * The only rewritten queries follow these notation: INSERT [LOW_PRIORITY | DELAYED |
253
- * HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION (partition_list)] [(col,...)] {VALUES |
254
- * VALUE} (...) [ ON DUPLICATE KEY UPDATE col=expr [, col=expr] ... ] With expr without
255
- * parameter.
256
- *
257
- * Query with INSERT ... SELECT / containing LAST_INSERT_ID() will not be rewritten
258
- *
259
- * query parts will be split this way :
260
- * - pre-value part
261
- * - after value part
262
- * [- after parameter part] (after each parameter)
263
- * - ending part
264
- *
265
- * example : INSERT INTO MyTABLE VALUES (9, ?, 5, ?, 8) ON DUPLICATE KEY UPDATE col2=col2+10
266
- * will result in :
267
- * - pre-value : "INSERT INTO MyTABLE VALUES"
268
- * - after value : " (9, "
269
- * - after parameter : ", 5, "
270
- * - after parameter : ", 8)"
271
- * - ending : " ON DUPLICATE KEY UPDATE col2=col2+10"
272
- *
273
- *
274
- * @returns {JSON} query separated by parameters
275
- */
276
- module.exports.splitRewritableQuery = function (sql) {
277
- let reWritablePrepare = true;
278
- let multipleQueriesPrepare = true;
279
- let partList = [];
280
- let lastChar = '\0';
281
-
282
- let lastParameterPosition = 0;
283
-
284
- let preValuePart1 = null;
285
- let preValuePart2 = null;
286
- let postValuePart = null;
287
-
288
- let singleQuotes = false;
289
-
290
- let isInParenthesis = 0;
291
- let isFirstChar = true;
292
- let isInsert = false;
293
- let semicolon = false;
294
- let hasParam = false;
295
- let state = State.Normal;
296
-
297
- let idx = 0;
298
- let car = sql.charAt(idx++);
299
- while (car !== '') {
300
- if (
301
- state === State.Escape &&
302
- !((car === "'" && singleQuotes) || (car === '"' && !singleQuotes))
303
- ) {
304
- state = State.String;
305
- car = sql.charAt(idx++);
306
- continue;
307
- }
308
-
309
- switch (car) {
310
- case '*':
311
- if (state === State.Normal && lastChar == '/') {
312
- state = State.SlashStarComment;
313
- }
314
- break;
315
-
316
- case '/':
317
- if (state === State.SlashStarComment && lastChar == '*') {
318
- state = State.Normal;
319
- }
320
- break;
321
-
322
- case '#':
323
- if (state === State.Normal) {
324
- state = State.EOLComment;
325
- }
326
- break;
327
-
328
- case '-':
329
- if (state === State.Normal && lastChar == '-') {
330
- state = State.EOLComment;
331
- }
332
- break;
333
-
334
- case '\n':
335
- if (state === State.EOLComment) {
336
- state = State.Normal;
337
- }
338
- break;
339
-
340
- case '"':
341
- if (state === State.Normal) {
342
- state = State.String;
343
- singleQuotes = false;
344
- } else if (state === State.String && !singleQuotes) {
345
- state = State.Normal;
346
- } else if (state === State.Escape && !singleQuotes) {
347
- state = State.String;
348
- }
349
- break;
350
- case ';':
351
- if (state === State.Normal) {
352
- semicolon = true;
353
- multipleQueriesPrepare = false;
354
- }
355
- break;
356
- case "'":
357
- if (state === State.Normal) {
358
- state = State.String;
359
- singleQuotes = true;
360
- } else if (state === State.String && singleQuotes) {
361
- state = State.Normal;
362
- } else if (state === State.Escape && singleQuotes) {
363
- state = State.String;
364
- }
365
- break;
366
-
367
- case '\\':
368
- if (state === State.String) {
369
- state = State.Escape;
370
- }
371
- break;
372
-
373
- case '?':
374
- if (state === State.Normal) {
375
- hasParam = true;
376
- let part = sql.substring(lastParameterPosition, idx - 1);
377
- lastParameterPosition = idx;
378
-
379
- if (preValuePart1 === null) {
380
- preValuePart1 = part;
381
- preValuePart2 = '';
382
- } else if (preValuePart2 === null) {
383
- preValuePart2 = part;
384
- } else {
385
- if (postValuePart) {
386
- //having parameters after the last ")" of value is not rewritable
387
- reWritablePrepare = false;
388
- partList.push(postValuePart + part);
389
- postValuePart = null;
390
- } else partList.push(part);
391
- }
392
- }
393
- break;
394
- case '`':
395
- if (state === State.Backtick) {
396
- state = State.Normal;
397
- } else if (state === State.Normal) {
398
- state = State.Backtick;
399
- }
400
- break;
401
-
402
- case 's':
403
- case 'S':
404
- if (
405
- state === State.Normal &&
406
- postValuePart === null &&
407
- sql.length > idx + 5 &&
408
- (sql.charAt(idx) === 'e' || sql.charAt(idx) === 'E') &&
409
- (sql.charAt(idx + 1) === 'l' || sql.charAt(idx + 1) === 'L') &&
410
- (sql.charAt(idx + 2) === 'e' || sql.charAt(idx + 2) === 'E') &&
411
- (sql.charAt(idx + 3) === 'c' || sql.charAt(idx + 3) === 'C') &&
412
- (sql.charAt(idx + 4) === 't' || sql.charAt(idx + 4) === 'T')
413
- ) {
414
- //field/table name might contain 'select'
415
- if (
416
- idx > 1 &&
417
- sql.charAt(idx - 2) > ' ' &&
418
- '();><=-+,'.indexOf(sql.charAt(idx - 2)) === -1
419
- ) {
420
- break;
421
- }
422
- if (sql.charAt(idx + 5) > ' ' && '();><=-+,'.indexOf(sql.charAt(idx + 5)) === -1) {
423
- break;
424
- }
425
-
426
- //SELECT queries, INSERT FROM SELECT not rewritable
427
- reWritablePrepare = false;
428
- }
429
- break;
430
- case 'v':
431
- case 'V':
432
- if (
433
- state === State.Normal &&
434
- !preValuePart1 &&
435
- (lastChar == ')' || lastChar <= ' ') &&
436
- sql.length > idx + 6 &&
437
- (sql.charAt(idx) === 'a' || sql.charAt(idx) === 'A') &&
438
- (sql.charAt(idx + 1) === 'l' || sql.charAt(idx + 1) === 'L') &&
439
- (sql.charAt(idx + 2) === 'u' || sql.charAt(idx + 2) === 'U') &&
440
- (sql.charAt(idx + 3) === 'e' || sql.charAt(idx + 3) === 'E') &&
441
- (sql.charAt(idx + 4) === 's' || sql.charAt(idx + 4) === 'S') &&
442
- (sql.charAt(idx + 5) === '(' || sql.charAt(idx + 5) <= ' ')
443
- ) {
444
- idx += 5;
445
- preValuePart1 = sql.substring(lastParameterPosition, idx);
446
- lastParameterPosition = idx;
447
- }
448
- break;
449
- case 'l':
450
- case 'L':
451
- if (
452
- state === State.Normal &&
453
- sql.length > idx + 13 &&
454
- (sql.charAt(idx) === 'a' || sql.charAt(idx) === 'A') &&
455
- (sql.charAt(idx + 1) === 's' || sql.charAt(idx + 1) === 'S') &&
456
- (sql.charAt(idx + 2) === 't' || sql.charAt(idx + 2) === 'T') &&
457
- sql.charAt(idx + 3) === '_' &&
458
- (sql.charAt(idx + 4) === 'i' || sql.charAt(idx + 4) === 'I') &&
459
- (sql.charAt(idx + 5) === 'n' || sql.charAt(idx + 5) === 'N') &&
460
- (sql.charAt(idx + 6) === 's' || sql.charAt(idx + 6) === 'S') &&
461
- (sql.charAt(idx + 7) === 'e' || sql.charAt(idx + 7) === 'E') &&
462
- (sql.charAt(idx + 8) === 'r' || sql.charAt(idx + 8) === 'R') &&
463
- (sql.charAt(idx + 9) === 't' || sql.charAt(idx + 9) === 'T') &&
464
- sql.charAt(idx + 10) === '_' &&
465
- (sql.charAt(idx + 11) === 'i' || sql.charAt(idx + 11) === 'I') &&
466
- (sql.charAt(idx + 12) === 'd' || sql.charAt(idx + 12) === 'D') &&
467
- sql.charAt(idx + 13) === '('
468
- ) {
469
- reWritablePrepare = false;
470
- idx += 13;
471
- }
472
- break;
473
- case '(':
474
- if (state === State.Normal) {
475
- isInParenthesis++;
476
- }
477
- break;
478
- case ')':
479
- if (state === State.Normal) {
480
- isInParenthesis--;
481
- if (isInParenthesis === 0 && preValuePart2 !== null && postValuePart === null) {
482
- postValuePart = sql.substring(lastParameterPosition, idx);
483
- lastParameterPosition = idx;
484
- }
485
- }
486
- break;
487
- default:
488
- if (state === State.Normal && isFirstChar && car > ' ') {
489
- if (
490
- (car === 'I' || car === 'i') &&
491
- sql.length > idx + 6 &&
492
- (sql.charAt(idx) === 'n' || sql.charAt(idx) === 'N') &&
493
- (sql.charAt(idx + 1) === 's' || sql.charAt(idx + 1) === 'S') &&
494
- (sql.charAt(idx + 2) === 'e' || sql.charAt(idx + 2) === 'E') &&
495
- (sql.charAt(idx + 3) === 'r' || sql.charAt(idx + 3) === 'R') &&
496
- (sql.charAt(idx + 4) === 't' || sql.charAt(idx + 4) === 'T') &&
497
- (sql.charAt(idx + 5) === '(' || sql.charAt(idx + 5) <= ' ')
498
- ) {
499
- isInsert = true;
500
- }
501
- isFirstChar = false;
502
- }
503
- //multiple queries
504
- if (state === State.Normal && semicolon && car >= ' ') {
505
- reWritablePrepare = false;
506
- multipleQueriesPrepare = true;
507
- }
508
- break;
509
- }
510
-
511
- lastChar = car;
512
- car = sql.charAt(idx++);
513
- }
514
-
515
- if (state === State.EOLComment) multipleQueriesPrepare = false;
516
-
517
- if (!hasParam) {
518
- //permit to have rewrite without parameter
519
- if (preValuePart1 === null) {
520
- partList.unshift('');
521
- partList.unshift(sql);
522
- } else {
523
- partList.unshift(sql.substring(lastParameterPosition, idx));
524
- partList.unshift(preValuePart1);
525
- }
526
- lastParameterPosition = idx;
527
- } else {
528
- partList.unshift(preValuePart2 !== null ? preValuePart2 : '');
529
- partList.unshift(preValuePart1 !== null ? preValuePart1 : '');
530
- }
531
-
532
- if (!isInsert) {
533
- reWritablePrepare = false;
534
- }
535
-
536
- //postValuePart is the value after the last parameter and parenthesis
537
- //if no param, don't add to the list.
538
- if (hasParam) {
539
- partList.push(postValuePart !== null ? postValuePart : '');
540
- }
541
- partList.push(sql.substring(lastParameterPosition, idx));
542
-
543
- return {
544
- partList: partList,
545
- reWritable: reWritablePrepare,
546
- multipleQueries: multipleQueriesPrepare
547
- };
548
- };
549
-
550
- module.exports.searchPlaceholder = function (sql, info, initialValues, displaySql) {
551
- let sqlPlaceHolder = '';
552
- const rowNumber = initialValues.length;
553
- let values = new Array(rowNumber);
554
- for (let i = 0; i < rowNumber; i++) values[i] = [];
555
- let state = State.Normal;
556
- let lastChar = '\0';
557
-
558
- let singleQuotes = false;
559
- let lastParameterPosition = 0;
560
-
561
- let idx = 0;
562
- let car = sql.charAt(idx++);
563
- let placeholderName;
564
-
565
- while (car !== '') {
566
- if (
567
- state === State.Escape &&
568
- !((car === "'" && singleQuotes) || (car === '"' && !singleQuotes))
569
- ) {
570
- state = State.String;
571
- lastChar = car;
572
- car = sql.charAt(idx++);
573
- continue;
574
- }
575
-
576
- switch (car) {
577
- case '*':
578
- if (state === State.Normal && lastChar == '/') state = State.SlashStarComment;
579
- break;
580
-
581
- case '/':
582
- if (state === State.SlashStarComment && lastChar == '*') state = State.Normal;
583
- break;
584
-
585
- case '#':
586
- if (state === State.Normal) state = State.EOLComment;
587
- break;
588
-
589
- case '-':
590
- if (state === State.Normal && lastChar == '-') {
591
- state = State.EOLComment;
592
- }
593
- break;
594
-
595
- case '\n':
596
- if (state === State.EOLComment) {
597
- state = State.Normal;
598
- }
599
- break;
600
-
601
- case '"':
602
- if (state === State.Normal) {
603
- state = State.String;
604
- singleQuotes = false;
605
- } else if (state === State.String && !singleQuotes) {
606
- state = State.Normal;
607
- } else if (state === State.Escape && !singleQuotes) {
608
- state = State.String;
609
- }
610
- break;
611
-
612
- case "'":
613
- if (state === State.Normal) {
614
- state = State.String;
615
- singleQuotes = true;
616
- } else if (state === State.String && singleQuotes) {
617
- state = State.Normal;
618
- singleQuotes = false;
619
- } else if (state === State.Escape && singleQuotes) {
620
- state = State.String;
621
- }
622
- break;
623
-
624
- case '\\':
625
- if (state === State.String) state = State.Escape;
626
- break;
627
-
628
- case ':':
629
- if (state === State.Normal) {
630
- sqlPlaceHolder += sql.substring(lastParameterPosition, idx - 1) + '?';
631
- placeholderName = '';
632
- while (
633
- ((car = sql.charAt(idx++)) !== '' && car >= '0' && car <= '9') ||
634
- (car >= 'A' && car <= 'Z') ||
635
- (car >= 'a' && car <= 'z') ||
636
- car === '-' ||
637
- car === '_'
638
- ) {
639
- placeholderName += car;
640
- }
641
- idx--;
642
- for (let i = 0; i < rowNumber; i++) {
643
- const val = initialValues[i][placeholderName];
644
- if (val !== undefined) {
645
- values[i].push(val);
646
- } else {
647
- values[i].push(null);
648
- }
649
- }
650
- lastParameterPosition = idx;
651
- }
652
- break;
653
- case '`':
654
- if (state === State.Backtick) {
655
- state = State.Normal;
656
- } else if (state === State.Normal) {
657
- state = State.Backtick;
658
- }
659
- }
660
- lastChar = car;
661
-
662
- car = sql.charAt(idx++);
663
- }
664
- if (lastParameterPosition === 0) {
665
- sqlPlaceHolder = sql;
666
- } else {
667
- sqlPlaceHolder += sql.substring(lastParameterPosition);
668
- }
669
-
670
- return { sql: sqlPlaceHolder, values: values };
671
- };
672
-
673
- /**
674
- * Split query according to named parameters.
675
- *
676
- * The only rewritten queries follow these notation: INSERT [LOW_PRIORITY | DELAYED |
677
- * HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION (partition_list)] [(col,...)] {VALUES |
678
- * VALUE} (...) [ ON DUPLICATE KEY UPDATE col=expr [, col=expr] ... ] With expr without
679
- * parameter.
680
- *
681
- * Query with INSERT ... SELECT / containing LAST_INSERT_ID() will not be rewritten
682
- *
683
- * query parts will be split this way :
684
- * - pre-value part
685
- * - after value part
686
- * [- after parameter part] (after each parameter)
687
- * - ending part
688
- *
689
- * example : INSERT INTO MyTABLE VALUES (9, :param1, 5, :param2, 8) ON DUPLICATE KEY UPDATE col2=col2+10
690
- * will result in :
691
- * - pre-value : "INSERT INTO MyTABLE VALUES"
692
- * - after value : " (9, "
693
- * - after parameter : ", 5, "
694
- * - after parameter : ", 8)"
695
- * - ending : " ON DUPLICATE KEY UPDATE col2=col2+10"
696
- *
697
- *
698
- * @returns {JSON} query separated by parameters
699
- */
700
- module.exports.splitRewritableNamedParameterQuery = function (sql, initialValues) {
701
- let reWritablePrepare = true;
702
- let multipleQueriesPrepare = true;
703
- let partList = [];
704
- let values = new Array(initialValues.length);
705
- for (let i = 0; i < values.length; i++) values[i] = [];
706
- let lastChar = '\0';
707
-
708
- let lastParameterPosition = 0;
709
-
710
- let preValuePart1 = null;
711
- let preValuePart2 = null;
712
- let postValuePart = null;
713
-
714
- let singleQuotes = false;
715
-
716
- let isInParenthesis = 0;
717
- let isFirstChar = true;
718
- let isInsert = false;
719
- let semicolon = false;
720
- let hasParam = false;
721
- let placeholderName;
722
- let state = State.Normal;
723
-
724
- let idx = 0;
725
- let car = sql.charAt(idx++);
726
- while (car !== '') {
727
- if (
728
- state === State.Escape &&
729
- !((car === "'" && singleQuotes) || (car === '"' && !singleQuotes))
730
- ) {
731
- state = State.String;
732
- car = sql.charAt(idx++);
733
- continue;
734
- }
735
-
736
- switch (car) {
737
- case '*':
738
- if (state === State.Normal && lastChar == '/') {
739
- state = State.SlashStarComment;
740
- }
741
- break;
742
-
743
- case '/':
744
- if (state === State.SlashStarComment && lastChar == '*') {
745
- state = State.Normal;
746
- }
747
- break;
748
-
749
- case '#':
750
- if (state === State.Normal) {
751
- state = State.EOLComment;
752
- }
753
- break;
754
-
755
- case '-':
756
- if (state === State.Normal && lastChar == '-') {
757
- state = State.EOLComment;
758
- }
759
- break;
760
-
761
- case '\n':
762
- if (state === State.EOLComment) {
763
- state = State.Normal;
764
- }
765
- break;
766
-
767
- case '"':
768
- if (state === State.Normal) {
769
- state = State.String;
770
- singleQuotes = false;
771
- } else if (state === State.String && !singleQuotes) {
772
- state = State.Normal;
773
- } else if (state === State.Escape && !singleQuotes) {
774
- state = State.String;
775
- }
776
- break;
777
- case ';':
778
- if (state === State.Normal) {
779
- semicolon = true;
780
- multipleQueriesPrepare = false;
781
- }
782
- break;
783
- case "'":
784
- if (state === State.Normal) {
785
- state = State.String;
786
- singleQuotes = true;
787
- } else if (state === State.String && singleQuotes) {
788
- state = State.Normal;
789
- } else if (state === State.Escape && singleQuotes) {
790
- state = State.String;
791
- }
792
- break;
793
-
794
- case '\\':
795
- if (state === State.String) {
796
- state = State.Escape;
797
- }
798
- break;
799
-
800
- case ':':
801
- if (state === State.Normal) {
802
- let part = sql.substring(lastParameterPosition, idx - 1);
803
- placeholderName = '';
804
- while (
805
- ((car = sql.charAt(idx++)) !== '' && car >= '0' && car <= '9') ||
806
- (car >= 'A' && car <= 'Z') ||
807
- (car >= 'a' && car <= 'z') ||
808
- car === '-' ||
809
- car === '_'
810
- ) {
811
- placeholderName += car;
812
- }
813
- idx--;
814
- hasParam = true;
815
- initialValues.forEach((row, idx) => {
816
- if (row[placeholderName] !== undefined) {
817
- values[idx].push(row[placeholderName]);
818
- } else {
819
- values[idx].push(null);
820
- }
821
- });
822
-
823
- lastParameterPosition = idx;
824
-
825
- if (preValuePart1 === null) {
826
- preValuePart1 = part;
827
- preValuePart2 = '';
828
- } else if (preValuePart2 === null) {
829
- preValuePart2 = part;
830
- } else {
831
- if (postValuePart) {
832
- //having parameters after the last ")" of value is not rewritable
833
- reWritablePrepare = false;
834
- partList.push(postValuePart + part);
835
- postValuePart = null;
836
- } else partList.push(part);
837
- }
838
- }
839
- break;
840
-
841
- case '`':
842
- if (state === State.Backtick) {
843
- state = State.Normal;
844
- } else if (state === State.Normal) {
845
- state = State.Backtick;
846
- }
847
- break;
848
-
849
- case 's':
850
- case 'S':
851
- if (
852
- state === State.Normal &&
853
- postValuePart === null &&
854
- sql.length > idx + 5 &&
855
- (sql.charAt(idx) === 'e' || sql.charAt(idx) === 'E') &&
856
- (sql.charAt(idx + 1) === 'l' || sql.charAt(idx + 1) === 'L') &&
857
- (sql.charAt(idx + 2) === 'e' || sql.charAt(idx + 2) === 'E') &&
858
- (sql.charAt(idx + 3) === 'c' || sql.charAt(idx + 3) === 'C') &&
859
- (sql.charAt(idx + 4) === 't' || sql.charAt(idx + 4) === 'T')
860
- ) {
861
- //field/table name might contain 'select'
862
- if (
863
- idx > 1 &&
864
- sql.charAt(idx - 2) > ' ' &&
865
- '();><=-+,'.indexOf(sql.charAt(idx - 2)) === -1
866
- ) {
867
- break;
868
- }
869
- if (sql.charAt(idx + 5) > ' ' && '();><=-+,'.indexOf(sql.charAt(idx + 5)) === -1) {
870
- break;
871
- }
872
-
873
- //SELECT queries, INSERT FROM SELECT not rewritable
874
- reWritablePrepare = false;
875
- }
876
- break;
877
- case 'v':
878
- case 'V':
879
- if (
880
- state === State.Normal &&
881
- !preValuePart1 &&
882
- (lastChar == ')' || lastChar <= ' ') &&
883
- sql.length > idx + 6 &&
884
- (sql.charAt(idx) === 'a' || sql.charAt(idx) === 'A') &&
885
- (sql.charAt(idx + 1) === 'l' || sql.charAt(idx + 1) === 'L') &&
886
- (sql.charAt(idx + 2) === 'u' || sql.charAt(idx + 2) === 'U') &&
887
- (sql.charAt(idx + 3) === 'e' || sql.charAt(idx + 3) === 'E') &&
888
- (sql.charAt(idx + 4) === 's' || sql.charAt(idx + 4) === 'S') &&
889
- (sql.charAt(idx + 5) === '(' || sql.charAt(idx + 5) <= ' ')
890
- ) {
891
- idx += 5;
892
- preValuePart1 = sql.substring(lastParameterPosition, idx);
893
- lastParameterPosition = idx;
894
- }
895
- break;
896
- case 'l':
897
- case 'L':
898
- if (
899
- state === State.Normal &&
900
- sql.length > idx + 13 &&
901
- (sql.charAt(idx) === 'a' || sql.charAt(idx) === 'A') &&
902
- (sql.charAt(idx + 1) === 's' || sql.charAt(idx + 1) === 'S') &&
903
- (sql.charAt(idx + 2) === 't' || sql.charAt(idx + 2) === 'T') &&
904
- sql.charAt(idx + 3) === '_' &&
905
- (sql.charAt(idx + 4) === 'i' || sql.charAt(idx + 4) === 'I') &&
906
- (sql.charAt(idx + 5) === 'n' || sql.charAt(idx + 5) === 'N') &&
907
- (sql.charAt(idx + 6) === 's' || sql.charAt(idx + 6) === 'S') &&
908
- (sql.charAt(idx + 7) === 'e' || sql.charAt(idx + 7) === 'E') &&
909
- (sql.charAt(idx + 8) === 'r' || sql.charAt(idx + 8) === 'R') &&
910
- (sql.charAt(idx + 9) === 't' || sql.charAt(idx + 9) === 'T') &&
911
- sql.charAt(idx + 10) === '_' &&
912
- (sql.charAt(idx + 11) === 'i' || sql.charAt(idx + 11) === 'I') &&
913
- (sql.charAt(idx + 12) === 'd' || sql.charAt(idx + 12) === 'D') &&
914
- sql.charAt(idx + 13) === '('
915
- ) {
916
- reWritablePrepare = false;
917
- idx += 13;
918
- }
919
- break;
920
- case '(':
921
- if (state === State.Normal) {
922
- isInParenthesis++;
923
- }
924
- break;
925
- case ')':
926
- if (state === State.Normal) {
927
- isInParenthesis--;
928
- if (isInParenthesis === 0 && preValuePart2 !== null && postValuePart === null) {
929
- postValuePart = sql.substring(lastParameterPosition, idx);
930
- lastParameterPosition = idx;
931
- }
932
- }
933
- break;
934
- default:
935
- if (state === State.Normal && isFirstChar && car > ' ') {
936
- if (
937
- (car === 'I' || car === 'i') &&
938
- sql.length > idx + 6 &&
939
- (sql.charAt(idx) === 'n' || sql.charAt(idx) === 'N') &&
940
- (sql.charAt(idx + 1) === 's' || sql.charAt(idx + 1) === 'S') &&
941
- (sql.charAt(idx + 2) === 'e' || sql.charAt(idx + 2) === 'E') &&
942
- (sql.charAt(idx + 3) === 'r' || sql.charAt(idx + 3) === 'R') &&
943
- (sql.charAt(idx + 4) === 't' || sql.charAt(idx + 4) === 'T') &&
944
- (sql.charAt(idx + 5) === '(' || sql.charAt(idx + 5) <= ' ')
945
- ) {
946
- isInsert = true;
947
- }
948
- isFirstChar = false;
949
- }
950
- //multiple queries
951
- if (state === State.Normal && semicolon && car >= ' ') {
952
- reWritablePrepare = false;
953
- multipleQueriesPrepare = true;
954
- }
955
- break;
956
- }
957
-
958
- lastChar = car;
959
- car = sql.charAt(idx++);
960
- }
961
-
962
- if (state === State.EOLComment) multipleQueriesPrepare = false;
963
-
964
- if (!hasParam) {
965
- //permit to have rewrite without parameter
966
- if (preValuePart1 === null) {
967
- partList.unshift('');
968
- partList.unshift(sql);
969
- } else {
970
- partList.unshift(sql.substring(lastParameterPosition, idx));
971
- partList.unshift(preValuePart1);
972
- }
973
- lastParameterPosition = idx;
974
- } else {
975
- partList.unshift(preValuePart2 !== null ? preValuePart2 : '');
976
- partList.unshift(preValuePart1 !== null ? preValuePart1 : '');
977
- }
978
-
979
- if (!isInsert) {
980
- reWritablePrepare = false;
981
- }
982
-
983
- //postValuePart is the value after the last parameter and parenthesis
984
- //if no param, don't add to the list.
985
- if (hasParam) {
986
- partList.push(postValuePart !== null ? postValuePart : '');
987
- }
988
- partList.push(sql.substring(lastParameterPosition, idx));
989
-
990
- return {
991
- partList: partList,
992
- reWritable: reWritablePrepare,
993
- multipleQueries: multipleQueriesPrepare,
994
- values: values
995
- };
996
- };
997
-
998
- /**
999
- * Ensure that filename requested by server corresponds to query
1000
- * protocol : https://mariadb.com/kb/en/library/local_infile-packet/
1001
- *
1002
- * @param sql query
1003
- * @param parameters parameters if any
1004
- * @param fileName server requested file
1005
- * @returns {boolean} is filename corresponding to query
1006
- */
1007
- module.exports.validateFileName = function (sql, parameters, fileName) {
1008
- // in case of windows, file name in query are escaped
1009
- // so for example LOAD DATA LOCAL INFILE 'C:\\Temp\\myFile.txt' ...
1010
- // but server return 'C:\Temp\myFile.txt'
1011
- // so with regex escaped, must test LOAD DATA LOCAL INFILE 'C:\\\\Temp\\\\myFile.txt'
1012
- let queryValidator = new RegExp(
1013
- "^(\\s*\\/\\*([^\\*]|\\*[^\\/])*\\*\\/)*\\s*LOAD\\s+DATA\\s+((LOW_PRIORITY|CONCURRENT)\\s+)?LOCAL\\s+INFILE\\s+'" +
1014
- fileName.replace(/\\/g, '\\\\\\\\').replace('.', '\\.') +
1015
- "'",
1016
- 'i'
1017
- );
1018
- if (queryValidator.test(sql)) return true;
1019
-
1020
- if (parameters != null) {
1021
- queryValidator = new RegExp(
1022
- '^(\\s*\\/\\*([^\\*]|\\*[^\\/])*\\*\\/)*\\s*LOAD\\s+DATA\\s+((LOW_PRIORITY|CONCURRENT)\\s+)?LOCAL\\s+INFILE\\s+\\?',
1023
- 'i'
1024
- );
1025
- if (queryValidator.test(sql) && parameters.length > 0) {
1026
- if (Array.isArray(parameters)) {
1027
- return parameters[0].toLowerCase() === fileName.toLowerCase();
1028
- }
1029
- return parameters.toLowerCase() === fileName.toLowerCase();
1030
- }
1031
- }
1032
- return false;
1033
- };