@nextcloud/files 3.2.1 → 3.3.1
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/dav/dav.d.ts +3 -24
- package/dist/fileAction.d.ts +1 -21
- package/dist/fileListHeaders.d.ts +1 -21
- package/dist/filename.d.ts +10 -0
- package/dist/files/file.d.ts +1 -21
- package/dist/files/folder.d.ts +1 -21
- package/dist/files/node.d.ts +33 -1
- package/dist/files/nodeData.d.ts +1 -21
- package/dist/index.cjs +2090 -1134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -25
- package/dist/index.mjs +2089 -1140
- package/dist/index.mjs.map +1 -1
- package/dist/navigation/column.d.ts +1 -21
- package/dist/navigation/navigation.d.ts +1 -21
- package/dist/navigation/view.d.ts +3 -22
- package/dist/newFileMenu.d.ts +23 -22
- package/dist/utils/logger.d.ts +1 -1
- package/dist/vendor.LICENSE.txt +1 -1
- package/package.json +13 -12
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getCurrentUser
|
|
2
|
-
import { getLoggerBuilder
|
|
3
|
-
import { getCanonicalLocale
|
|
4
|
-
import { join
|
|
5
|
-
import { encodePath
|
|
6
|
-
import { generateRemoteUrl
|
|
7
|
-
import { createClient
|
|
8
|
-
import { CancelablePromise
|
|
1
|
+
import { getCurrentUser, onRequestTokenUpdate, getRequestToken } from "@nextcloud/auth";
|
|
2
|
+
import { getLoggerBuilder } from "@nextcloud/logger";
|
|
3
|
+
import { getCanonicalLocale } from "@nextcloud/l10n";
|
|
4
|
+
import { join, basename, extname, dirname } from "path";
|
|
5
|
+
import { encodePath } from "@nextcloud/paths";
|
|
6
|
+
import { generateRemoteUrl } from "@nextcloud/router";
|
|
7
|
+
import { createClient, getPatcher } from "webdav";
|
|
8
|
+
import { CancelablePromise } from "cancelable-promise";
|
|
9
9
|
/**
|
|
10
10
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
11
11
|
*
|
|
@@ -27,7 +27,13 @@ import { CancelablePromise as me } from "cancelable-promise";
|
|
|
27
27
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
28
28
|
*
|
|
29
29
|
*/
|
|
30
|
-
const
|
|
30
|
+
const getLogger = (user) => {
|
|
31
|
+
if (user === null) {
|
|
32
|
+
return getLoggerBuilder().setApp("files").build();
|
|
33
|
+
}
|
|
34
|
+
return getLoggerBuilder().setApp("files").setUid(user.uid).build();
|
|
35
|
+
};
|
|
36
|
+
const logger = getLogger(getCurrentUser());
|
|
31
37
|
/**
|
|
32
38
|
* @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
|
|
33
39
|
*
|
|
@@ -49,49 +55,71 @@ const Ne = (e) => e === null ? B().setApp("files").build() : B().setApp("files")
|
|
|
49
55
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
50
56
|
*
|
|
51
57
|
*/
|
|
52
|
-
|
|
58
|
+
var NewMenuEntryCategory = /* @__PURE__ */ ((NewMenuEntryCategory2) => {
|
|
59
|
+
NewMenuEntryCategory2[NewMenuEntryCategory2["UploadFromDevice"] = 0] = "UploadFromDevice";
|
|
60
|
+
NewMenuEntryCategory2[NewMenuEntryCategory2["CreateNew"] = 1] = "CreateNew";
|
|
61
|
+
NewMenuEntryCategory2[NewMenuEntryCategory2["Other"] = 2] = "Other";
|
|
62
|
+
return NewMenuEntryCategory2;
|
|
63
|
+
})(NewMenuEntryCategory || {});
|
|
64
|
+
class NewFileMenu {
|
|
53
65
|
_entries = [];
|
|
54
|
-
registerEntry(
|
|
55
|
-
this.validateEntry(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
registerEntry(entry) {
|
|
67
|
+
this.validateEntry(entry);
|
|
68
|
+
entry.category = entry.category ?? 1;
|
|
69
|
+
this._entries.push(entry);
|
|
70
|
+
}
|
|
71
|
+
unregisterEntry(entry) {
|
|
72
|
+
const entryIndex = typeof entry === "string" ? this.getEntryIndex(entry) : this.getEntryIndex(entry.id);
|
|
73
|
+
if (entryIndex === -1) {
|
|
74
|
+
logger.warn("Entry not found, nothing removed", { entry, entries: this.getEntries() });
|
|
61
75
|
return;
|
|
62
76
|
}
|
|
63
|
-
this._entries.splice(
|
|
77
|
+
this._entries.splice(entryIndex, 1);
|
|
64
78
|
}
|
|
65
79
|
/**
|
|
66
80
|
* Get the list of registered entries
|
|
67
81
|
*
|
|
68
82
|
* @param {Folder} context the creation context. Usually the current folder
|
|
69
83
|
*/
|
|
70
|
-
getEntries(
|
|
71
|
-
|
|
84
|
+
getEntries(context) {
|
|
85
|
+
if (context) {
|
|
86
|
+
return this._entries.filter((entry) => typeof entry.enabled === "function" ? entry.enabled(context) : true);
|
|
87
|
+
}
|
|
88
|
+
return this._entries;
|
|
72
89
|
}
|
|
73
|
-
getEntryIndex(
|
|
74
|
-
return this._entries.findIndex((
|
|
90
|
+
getEntryIndex(id) {
|
|
91
|
+
return this._entries.findIndex((entry) => entry.id === id);
|
|
75
92
|
}
|
|
76
|
-
validateEntry(
|
|
77
|
-
if (!
|
|
93
|
+
validateEntry(entry) {
|
|
94
|
+
if (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass) || !entry.handler) {
|
|
78
95
|
throw new Error("Invalid entry");
|
|
79
|
-
|
|
96
|
+
}
|
|
97
|
+
if (typeof entry.id !== "string" || typeof entry.displayName !== "string") {
|
|
80
98
|
throw new Error("Invalid id or displayName property");
|
|
81
|
-
|
|
99
|
+
}
|
|
100
|
+
if (entry.iconClass && typeof entry.iconClass !== "string" || entry.iconSvgInline && typeof entry.iconSvgInline !== "string") {
|
|
82
101
|
throw new Error("Invalid icon provided");
|
|
83
|
-
|
|
102
|
+
}
|
|
103
|
+
if (entry.enabled !== void 0 && typeof entry.enabled !== "function") {
|
|
84
104
|
throw new Error("Invalid enabled property");
|
|
85
|
-
|
|
105
|
+
}
|
|
106
|
+
if (typeof entry.handler !== "function") {
|
|
86
107
|
throw new Error("Invalid handler property");
|
|
87
|
-
|
|
108
|
+
}
|
|
109
|
+
if ("order" in entry && typeof entry.order !== "number") {
|
|
88
110
|
throw new Error("Invalid order property");
|
|
89
|
-
|
|
111
|
+
}
|
|
112
|
+
if (this.getEntryIndex(entry.id) !== -1) {
|
|
90
113
|
throw new Error("Duplicate entry");
|
|
114
|
+
}
|
|
91
115
|
}
|
|
92
116
|
}
|
|
93
|
-
const
|
|
94
|
-
|
|
117
|
+
const getNewFileMenu = function() {
|
|
118
|
+
if (typeof window._nc_newfilemenu === "undefined") {
|
|
119
|
+
window._nc_newfilemenu = new NewFileMenu();
|
|
120
|
+
logger.debug("NewFileMenu initialized");
|
|
121
|
+
}
|
|
122
|
+
return window._nc_newfilemenu;
|
|
95
123
|
};
|
|
96
124
|
/**
|
|
97
125
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
@@ -115,25 +143,38 @@ const F = function() {
|
|
|
115
143
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
116
144
|
*
|
|
117
145
|
*/
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
146
|
+
const humanList = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
147
|
+
const humanListBinary = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
|
|
148
|
+
function formatFileSize(size, skipSmallSizes = false, binaryPrefixes = false, base1000 = false) {
|
|
149
|
+
binaryPrefixes = binaryPrefixes && !base1000;
|
|
150
|
+
if (typeof size === "string") {
|
|
151
|
+
size = Number(size);
|
|
152
|
+
}
|
|
153
|
+
let order = size > 0 ? Math.floor(Math.log(size) / Math.log(base1000 ? 1e3 : 1024)) : 0;
|
|
154
|
+
order = Math.min((binaryPrefixes ? humanListBinary.length : humanList.length) - 1, order);
|
|
155
|
+
const readableFormat = binaryPrefixes ? humanListBinary[order] : humanList[order];
|
|
156
|
+
let relativeSize = (size / Math.pow(base1000 ? 1e3 : 1024, order)).toFixed(1);
|
|
157
|
+
if (skipSmallSizes === true && order === 0) {
|
|
158
|
+
return (relativeSize !== "0.0" ? "< 1 " : "0 ") + (binaryPrefixes ? humanListBinary[1] : humanList[1]);
|
|
159
|
+
}
|
|
160
|
+
if (order < 2) {
|
|
161
|
+
relativeSize = parseFloat(relativeSize).toFixed(0);
|
|
162
|
+
} else {
|
|
163
|
+
relativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale());
|
|
164
|
+
}
|
|
165
|
+
return relativeSize + " " + readableFormat;
|
|
166
|
+
}
|
|
167
|
+
function parseFileSize(value, forceBinary = false) {
|
|
128
168
|
try {
|
|
129
|
-
|
|
130
|
-
} catch {
|
|
169
|
+
value = `${value}`.toLocaleLowerCase().replaceAll(/\s+/g, "").replaceAll(",", ".");
|
|
170
|
+
} catch (e) {
|
|
131
171
|
return null;
|
|
132
172
|
}
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
173
|
+
const match = value.match(/^([0-9]*(\.[0-9]*)?)([kmgtp]?)(i?)b?$/);
|
|
174
|
+
if (match === null || match[1] === "." || match[1] === "") {
|
|
135
175
|
return null;
|
|
136
|
-
|
|
176
|
+
}
|
|
177
|
+
const bytesArray = {
|
|
137
178
|
"": 0,
|
|
138
179
|
k: 1,
|
|
139
180
|
m: 2,
|
|
@@ -141,8 +182,10 @@ function Dt(e, t = !1) {
|
|
|
141
182
|
t: 4,
|
|
142
183
|
p: 5,
|
|
143
184
|
e: 6
|
|
144
|
-
}
|
|
145
|
-
|
|
185
|
+
};
|
|
186
|
+
const decimalString = `${match[1]}`;
|
|
187
|
+
const base = match[4] === "i" || forceBinary ? 1024 : 1e3;
|
|
188
|
+
return Math.round(Number.parseFloat(decimalString) * base ** bytesArray[match[3]]);
|
|
146
189
|
}
|
|
147
190
|
/**
|
|
148
191
|
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
|
@@ -165,11 +208,16 @@ function Dt(e, t = !1) {
|
|
|
165
208
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
166
209
|
*
|
|
167
210
|
*/
|
|
168
|
-
var
|
|
169
|
-
|
|
211
|
+
var DefaultType = /* @__PURE__ */ ((DefaultType2) => {
|
|
212
|
+
DefaultType2["DEFAULT"] = "default";
|
|
213
|
+
DefaultType2["HIDDEN"] = "hidden";
|
|
214
|
+
return DefaultType2;
|
|
215
|
+
})(DefaultType || {});
|
|
216
|
+
class FileAction {
|
|
170
217
|
_action;
|
|
171
|
-
constructor(
|
|
172
|
-
this.validateAction(
|
|
218
|
+
constructor(action) {
|
|
219
|
+
this.validateAction(action);
|
|
220
|
+
this._action = action;
|
|
173
221
|
}
|
|
174
222
|
get id() {
|
|
175
223
|
return this._action.id;
|
|
@@ -207,41 +255,62 @@ class er {
|
|
|
207
255
|
get renderInline() {
|
|
208
256
|
return this._action.renderInline;
|
|
209
257
|
}
|
|
210
|
-
validateAction(
|
|
211
|
-
if (!
|
|
258
|
+
validateAction(action) {
|
|
259
|
+
if (!action.id || typeof action.id !== "string") {
|
|
212
260
|
throw new Error("Invalid id");
|
|
213
|
-
|
|
261
|
+
}
|
|
262
|
+
if (!action.displayName || typeof action.displayName !== "function") {
|
|
214
263
|
throw new Error("Invalid displayName function");
|
|
215
|
-
|
|
264
|
+
}
|
|
265
|
+
if ("title" in action && typeof action.title !== "function") {
|
|
216
266
|
throw new Error("Invalid title function");
|
|
217
|
-
|
|
267
|
+
}
|
|
268
|
+
if (!action.iconSvgInline || typeof action.iconSvgInline !== "function") {
|
|
218
269
|
throw new Error("Invalid iconSvgInline function");
|
|
219
|
-
|
|
270
|
+
}
|
|
271
|
+
if (!action.exec || typeof action.exec !== "function") {
|
|
220
272
|
throw new Error("Invalid exec function");
|
|
221
|
-
|
|
273
|
+
}
|
|
274
|
+
if ("enabled" in action && typeof action.enabled !== "function") {
|
|
222
275
|
throw new Error("Invalid enabled function");
|
|
223
|
-
|
|
276
|
+
}
|
|
277
|
+
if ("execBatch" in action && typeof action.execBatch !== "function") {
|
|
224
278
|
throw new Error("Invalid execBatch function");
|
|
225
|
-
|
|
279
|
+
}
|
|
280
|
+
if ("order" in action && typeof action.order !== "number") {
|
|
226
281
|
throw new Error("Invalid order");
|
|
227
|
-
|
|
282
|
+
}
|
|
283
|
+
if ("parent" in action && typeof action.parent !== "string") {
|
|
228
284
|
throw new Error("Invalid parent");
|
|
229
|
-
|
|
285
|
+
}
|
|
286
|
+
if (action.default && !Object.values(DefaultType).includes(action.default)) {
|
|
230
287
|
throw new Error("Invalid default");
|
|
231
|
-
|
|
288
|
+
}
|
|
289
|
+
if ("inline" in action && typeof action.inline !== "function") {
|
|
232
290
|
throw new Error("Invalid inline function");
|
|
233
|
-
|
|
291
|
+
}
|
|
292
|
+
if ("renderInline" in action && typeof action.renderInline !== "function") {
|
|
234
293
|
throw new Error("Invalid renderInline function");
|
|
294
|
+
}
|
|
235
295
|
}
|
|
236
296
|
}
|
|
237
|
-
const
|
|
238
|
-
if (typeof window._nc_fileactions
|
|
239
|
-
|
|
297
|
+
const registerFileAction = function(action) {
|
|
298
|
+
if (typeof window._nc_fileactions === "undefined") {
|
|
299
|
+
window._nc_fileactions = [];
|
|
300
|
+
logger.debug("FileActions initialized");
|
|
301
|
+
}
|
|
302
|
+
if (window._nc_fileactions.find((search) => search.id === action.id)) {
|
|
303
|
+
logger.error(`FileAction ${action.id} already registered`, { action });
|
|
240
304
|
return;
|
|
241
305
|
}
|
|
242
|
-
window._nc_fileactions.push(
|
|
243
|
-
}
|
|
244
|
-
|
|
306
|
+
window._nc_fileactions.push(action);
|
|
307
|
+
};
|
|
308
|
+
const getFileActions = function() {
|
|
309
|
+
if (typeof window._nc_fileactions === "undefined") {
|
|
310
|
+
window._nc_fileactions = [];
|
|
311
|
+
logger.debug("FileActions initialized");
|
|
312
|
+
}
|
|
313
|
+
return window._nc_fileactions;
|
|
245
314
|
};
|
|
246
315
|
/**
|
|
247
316
|
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
|
@@ -264,10 +333,11 @@ const tr = function(e) {
|
|
|
264
333
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
265
334
|
*
|
|
266
335
|
*/
|
|
267
|
-
class
|
|
336
|
+
class Header {
|
|
268
337
|
_header;
|
|
269
|
-
constructor(
|
|
270
|
-
this.validateHeader(
|
|
338
|
+
constructor(header) {
|
|
339
|
+
this.validateHeader(header);
|
|
340
|
+
this._header = header;
|
|
271
341
|
}
|
|
272
342
|
get id() {
|
|
273
343
|
return this._header.id;
|
|
@@ -284,27 +354,41 @@ class nr {
|
|
|
284
354
|
get updated() {
|
|
285
355
|
return this._header.updated;
|
|
286
356
|
}
|
|
287
|
-
validateHeader(
|
|
288
|
-
if (!
|
|
357
|
+
validateHeader(header) {
|
|
358
|
+
if (!header.id || !header.render || !header.updated) {
|
|
289
359
|
throw new Error("Invalid header: id, render and updated are required");
|
|
290
|
-
|
|
360
|
+
}
|
|
361
|
+
if (typeof header.id !== "string") {
|
|
291
362
|
throw new Error("Invalid id property");
|
|
292
|
-
|
|
363
|
+
}
|
|
364
|
+
if (header.enabled !== void 0 && typeof header.enabled !== "function") {
|
|
293
365
|
throw new Error("Invalid enabled property");
|
|
294
|
-
|
|
366
|
+
}
|
|
367
|
+
if (header.render && typeof header.render !== "function") {
|
|
295
368
|
throw new Error("Invalid render property");
|
|
296
|
-
|
|
369
|
+
}
|
|
370
|
+
if (header.updated && typeof header.updated !== "function") {
|
|
297
371
|
throw new Error("Invalid updated property");
|
|
372
|
+
}
|
|
298
373
|
}
|
|
299
374
|
}
|
|
300
|
-
const
|
|
301
|
-
if (typeof window._nc_filelistheader
|
|
302
|
-
|
|
375
|
+
const registerFileListHeaders = function(header) {
|
|
376
|
+
if (typeof window._nc_filelistheader === "undefined") {
|
|
377
|
+
window._nc_filelistheader = [];
|
|
378
|
+
logger.debug("FileListHeaders initialized");
|
|
379
|
+
}
|
|
380
|
+
if (window._nc_filelistheader.find((search) => search.id === header.id)) {
|
|
381
|
+
logger.error(`Header ${header.id} already registered`, { header });
|
|
303
382
|
return;
|
|
304
383
|
}
|
|
305
|
-
window._nc_filelistheader.push(
|
|
306
|
-
}
|
|
307
|
-
|
|
384
|
+
window._nc_filelistheader.push(header);
|
|
385
|
+
};
|
|
386
|
+
const getFileListHeaders = function() {
|
|
387
|
+
if (typeof window._nc_filelistheader === "undefined") {
|
|
388
|
+
window._nc_filelistheader = [];
|
|
389
|
+
logger.debug("FileListHeaders initialized");
|
|
390
|
+
}
|
|
391
|
+
return window._nc_filelistheader;
|
|
308
392
|
};
|
|
309
393
|
/**
|
|
310
394
|
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
@@ -327,7 +411,16 @@ const ir = function(e) {
|
|
|
327
411
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
328
412
|
*
|
|
329
413
|
*/
|
|
330
|
-
var
|
|
414
|
+
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
415
|
+
Permission2[Permission2["NONE"] = 0] = "NONE";
|
|
416
|
+
Permission2[Permission2["CREATE"] = 4] = "CREATE";
|
|
417
|
+
Permission2[Permission2["READ"] = 1] = "READ";
|
|
418
|
+
Permission2[Permission2["UPDATE"] = 2] = "UPDATE";
|
|
419
|
+
Permission2[Permission2["DELETE"] = 8] = "DELETE";
|
|
420
|
+
Permission2[Permission2["SHARE"] = 16] = "SHARE";
|
|
421
|
+
Permission2[Permission2["ALL"] = 31] = "ALL";
|
|
422
|
+
return Permission2;
|
|
423
|
+
})(Permission || {});
|
|
331
424
|
/**
|
|
332
425
|
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
|
333
426
|
*
|
|
@@ -350,7 +443,7 @@ var N = /* @__PURE__ */ ((e) => (e[e.NONE = 0] = "NONE", e[e.CREATE = 4] = "CREA
|
|
|
350
443
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
351
444
|
*
|
|
352
445
|
*/
|
|
353
|
-
const
|
|
446
|
+
const defaultDavProperties = [
|
|
354
447
|
"d:getcontentlength",
|
|
355
448
|
"d:getcontenttype",
|
|
356
449
|
"d:getetag",
|
|
@@ -367,54 +460,80 @@ const Z = [
|
|
|
367
460
|
"oc:owner-id",
|
|
368
461
|
"oc:permissions",
|
|
369
462
|
"oc:size"
|
|
370
|
-
]
|
|
463
|
+
];
|
|
464
|
+
const defaultDavNamespaces = {
|
|
371
465
|
d: "DAV:",
|
|
372
466
|
nc: "http://nextcloud.org/ns",
|
|
373
467
|
oc: "http://owncloud.org/ns",
|
|
374
468
|
ocs: "http://open-collaboration-services.org/ns"
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
469
|
+
};
|
|
470
|
+
const registerDavProperty = function(prop, namespace = { nc: "http://nextcloud.org/ns" }) {
|
|
471
|
+
if (typeof window._nc_dav_properties === "undefined") {
|
|
472
|
+
window._nc_dav_properties = [...defaultDavProperties];
|
|
473
|
+
window._nc_dav_namespaces = { ...defaultDavNamespaces };
|
|
474
|
+
}
|
|
475
|
+
const namespaces = { ...window._nc_dav_namespaces, ...namespace };
|
|
476
|
+
if (window._nc_dav_properties.find((search) => search === prop)) {
|
|
477
|
+
logger.warn(`${prop} already registered`, { prop });
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
if (prop.startsWith("<") || prop.split(":").length !== 2) {
|
|
481
|
+
logger.error(`${prop} is not valid. See example: 'oc:fileid'`, { prop });
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
const ns = prop.split(":")[0];
|
|
485
|
+
if (!namespaces[ns]) {
|
|
486
|
+
logger.error(`${prop} namespace unknown`, { prop, namespaces });
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
window._nc_dav_properties.push(prop);
|
|
490
|
+
window._nc_dav_namespaces = namespaces;
|
|
491
|
+
return true;
|
|
492
|
+
};
|
|
493
|
+
const getDavProperties = function() {
|
|
494
|
+
if (typeof window._nc_dav_properties === "undefined") {
|
|
495
|
+
window._nc_dav_properties = [...defaultDavProperties];
|
|
496
|
+
}
|
|
497
|
+
return window._nc_dav_properties.map((prop) => `<${prop} />`).join(" ");
|
|
498
|
+
};
|
|
499
|
+
const getDavNameSpaces = function() {
|
|
500
|
+
if (typeof window._nc_dav_namespaces === "undefined") {
|
|
501
|
+
window._nc_dav_namespaces = { ...defaultDavNamespaces };
|
|
502
|
+
}
|
|
503
|
+
return Object.keys(window._nc_dav_namespaces).map((ns) => `xmlns:${ns}="${window._nc_dav_namespaces?.[ns]}"`).join(" ");
|
|
504
|
+
};
|
|
505
|
+
const davGetDefaultPropfind = function() {
|
|
389
506
|
return `<?xml version="1.0"?>
|
|
390
|
-
<d:propfind ${
|
|
507
|
+
<d:propfind ${getDavNameSpaces()}>
|
|
391
508
|
<d:prop>
|
|
392
|
-
${
|
|
509
|
+
${getDavProperties()}
|
|
393
510
|
</d:prop>
|
|
394
511
|
</d:propfind>`;
|
|
395
|
-
}
|
|
512
|
+
};
|
|
513
|
+
const davGetFavoritesReport = function() {
|
|
396
514
|
return `<?xml version="1.0"?>
|
|
397
|
-
<oc:filter-files ${
|
|
515
|
+
<oc:filter-files ${getDavNameSpaces()}>
|
|
398
516
|
<d:prop>
|
|
399
|
-
${
|
|
517
|
+
${getDavProperties()}
|
|
400
518
|
</d:prop>
|
|
401
519
|
<oc:filter-rules>
|
|
402
520
|
<oc:favorite>1</oc:favorite>
|
|
403
521
|
</oc:filter-rules>
|
|
404
522
|
</oc:filter-files>`;
|
|
405
|
-
}
|
|
523
|
+
};
|
|
524
|
+
const davGetRecentSearch = function(lastModified) {
|
|
406
525
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
407
|
-
<d:searchrequest ${
|
|
526
|
+
<d:searchrequest ${getDavNameSpaces()}
|
|
408
527
|
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
|
|
409
528
|
<d:basicsearch>
|
|
410
529
|
<d:select>
|
|
411
530
|
<d:prop>
|
|
412
|
-
${
|
|
531
|
+
${getDavProperties()}
|
|
413
532
|
</d:prop>
|
|
414
533
|
</d:select>
|
|
415
534
|
<d:from>
|
|
416
535
|
<d:scope>
|
|
417
|
-
<d:href>/files/${
|
|
536
|
+
<d:href>/files/${getCurrentUser()?.uid}/</d:href>
|
|
418
537
|
<d:depth>infinity</d:depth>
|
|
419
538
|
</d:scope>
|
|
420
539
|
</d:from>
|
|
@@ -440,7 +559,7 @@ const Z = [
|
|
|
440
559
|
<d:prop>
|
|
441
560
|
<d:getlastmodified/>
|
|
442
561
|
</d:prop>
|
|
443
|
-
<d:literal>${
|
|
562
|
+
<d:literal>${lastModified}</d:literal>
|
|
444
563
|
</d:gt>
|
|
445
564
|
</d:and>
|
|
446
565
|
</d:where>
|
|
@@ -481,9 +600,27 @@ const Z = [
|
|
|
481
600
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
482
601
|
*
|
|
483
602
|
*/
|
|
484
|
-
const
|
|
485
|
-
let
|
|
486
|
-
|
|
603
|
+
const davParsePermissions = function(permString = "") {
|
|
604
|
+
let permissions = Permission.NONE;
|
|
605
|
+
if (!permString) {
|
|
606
|
+
return permissions;
|
|
607
|
+
}
|
|
608
|
+
if (permString.includes("C") || permString.includes("K")) {
|
|
609
|
+
permissions |= Permission.CREATE;
|
|
610
|
+
}
|
|
611
|
+
if (permString.includes("G")) {
|
|
612
|
+
permissions |= Permission.READ;
|
|
613
|
+
}
|
|
614
|
+
if (permString.includes("W") || permString.includes("N") || permString.includes("V")) {
|
|
615
|
+
permissions |= Permission.UPDATE;
|
|
616
|
+
}
|
|
617
|
+
if (permString.includes("D")) {
|
|
618
|
+
permissions |= Permission.DELETE;
|
|
619
|
+
}
|
|
620
|
+
if (permString.includes("R")) {
|
|
621
|
+
permissions |= Permission.SHARE;
|
|
622
|
+
}
|
|
623
|
+
return permissions;
|
|
487
624
|
};
|
|
488
625
|
/**
|
|
489
626
|
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
@@ -506,7 +643,11 @@ const ye = function(e = "") {
|
|
|
506
643
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
507
644
|
*
|
|
508
645
|
*/
|
|
509
|
-
var
|
|
646
|
+
var FileType = /* @__PURE__ */ ((FileType2) => {
|
|
647
|
+
FileType2["Folder"] = "folder";
|
|
648
|
+
FileType2["File"] = "file";
|
|
649
|
+
return FileType2;
|
|
650
|
+
})(FileType || {});
|
|
510
651
|
/**
|
|
511
652
|
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
512
653
|
*
|
|
@@ -528,47 +669,63 @@ var L = /* @__PURE__ */ ((e) => (e.Folder = "folder", e.File = "file", e))(L ||
|
|
|
528
669
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
529
670
|
*
|
|
530
671
|
*/
|
|
531
|
-
const
|
|
532
|
-
return
|
|
533
|
-
}
|
|
534
|
-
|
|
672
|
+
const isDavRessource = function(source, davService) {
|
|
673
|
+
return source.match(davService) !== null;
|
|
674
|
+
};
|
|
675
|
+
const validateData = (data, davService) => {
|
|
676
|
+
if (data.id && typeof data.id !== "number") {
|
|
535
677
|
throw new Error("Invalid id type of value");
|
|
536
|
-
|
|
678
|
+
}
|
|
679
|
+
if (!data.source) {
|
|
537
680
|
throw new Error("Missing mandatory source");
|
|
681
|
+
}
|
|
538
682
|
try {
|
|
539
|
-
new URL(
|
|
540
|
-
} catch {
|
|
683
|
+
new URL(data.source);
|
|
684
|
+
} catch (e) {
|
|
541
685
|
throw new Error("Invalid source format, source must be a valid URL");
|
|
542
686
|
}
|
|
543
|
-
if (!
|
|
687
|
+
if (!data.source.startsWith("http")) {
|
|
544
688
|
throw new Error("Invalid source format, only http(s) is supported");
|
|
545
|
-
|
|
689
|
+
}
|
|
690
|
+
if (data.mtime && !(data.mtime instanceof Date)) {
|
|
546
691
|
throw new Error("Invalid mtime type");
|
|
547
|
-
|
|
692
|
+
}
|
|
693
|
+
if (data.crtime && !(data.crtime instanceof Date)) {
|
|
548
694
|
throw new Error("Invalid crtime type");
|
|
549
|
-
|
|
695
|
+
}
|
|
696
|
+
if (!data.mime || typeof data.mime !== "string" || !data.mime.match(/^[-\w.]+\/[-+\w.]+$/gi)) {
|
|
550
697
|
throw new Error("Missing or invalid mandatory mime");
|
|
551
|
-
|
|
698
|
+
}
|
|
699
|
+
if ("size" in data && typeof data.size !== "number" && data.size !== void 0) {
|
|
552
700
|
throw new Error("Invalid size type");
|
|
553
|
-
|
|
701
|
+
}
|
|
702
|
+
if ("permissions" in data && data.permissions !== void 0 && !(typeof data.permissions === "number" && data.permissions >= Permission.NONE && data.permissions <= Permission.ALL)) {
|
|
554
703
|
throw new Error("Invalid permissions");
|
|
555
|
-
|
|
704
|
+
}
|
|
705
|
+
if (data.owner && data.owner !== null && typeof data.owner !== "string") {
|
|
556
706
|
throw new Error("Invalid owner type");
|
|
557
|
-
|
|
707
|
+
}
|
|
708
|
+
if (data.attributes && typeof data.attributes !== "object") {
|
|
558
709
|
throw new Error("Invalid attributes type");
|
|
559
|
-
|
|
710
|
+
}
|
|
711
|
+
if (data.root && typeof data.root !== "string") {
|
|
560
712
|
throw new Error("Invalid root type");
|
|
561
|
-
|
|
713
|
+
}
|
|
714
|
+
if (data.root && !data.root.startsWith("/")) {
|
|
562
715
|
throw new Error("Root must start with a leading slash");
|
|
563
|
-
|
|
716
|
+
}
|
|
717
|
+
if (data.root && !data.source.includes(data.root)) {
|
|
564
718
|
throw new Error("Root must be part of the source");
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
719
|
+
}
|
|
720
|
+
if (data.root && isDavRessource(data.source, davService)) {
|
|
721
|
+
const service = data.source.match(davService)[0];
|
|
722
|
+
if (!data.source.includes(join(service, data.root))) {
|
|
568
723
|
throw new Error("The root must be relative to the service. e.g /files/emma");
|
|
724
|
+
}
|
|
569
725
|
}
|
|
570
|
-
if (
|
|
726
|
+
if (data.status && !Object.values(NodeStatus).includes(data.status)) {
|
|
571
727
|
throw new Error("Status must be a valid NodeStatus");
|
|
728
|
+
}
|
|
572
729
|
};
|
|
573
730
|
/**
|
|
574
731
|
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
@@ -591,23 +748,42 @@ const Y = function(e, t) {
|
|
|
591
748
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
592
749
|
*
|
|
593
750
|
*/
|
|
594
|
-
var
|
|
595
|
-
|
|
751
|
+
var NodeStatus = /* @__PURE__ */ ((NodeStatus2) => {
|
|
752
|
+
NodeStatus2["NEW"] = "new";
|
|
753
|
+
NodeStatus2["FAILED"] = "failed";
|
|
754
|
+
NodeStatus2["LOADING"] = "loading";
|
|
755
|
+
NodeStatus2["LOCKED"] = "locked";
|
|
756
|
+
return NodeStatus2;
|
|
757
|
+
})(NodeStatus || {});
|
|
758
|
+
class Node {
|
|
596
759
|
_data;
|
|
597
760
|
_attributes;
|
|
598
761
|
_knownDavService = /(remote|public)\.php\/(web)?dav/i;
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
762
|
+
handler = {
|
|
763
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
764
|
+
set: (target, prop, value) => {
|
|
765
|
+
this.updateMtime();
|
|
766
|
+
return Reflect.set(target, prop, value);
|
|
767
|
+
},
|
|
768
|
+
deleteProperty: (target, prop) => {
|
|
769
|
+
this.updateMtime();
|
|
770
|
+
return Reflect.deleteProperty(target, prop);
|
|
771
|
+
}
|
|
772
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
773
|
+
};
|
|
774
|
+
constructor(data, davService) {
|
|
775
|
+
validateData(data, davService || this._knownDavService);
|
|
776
|
+
this._data = data;
|
|
777
|
+
this._attributes = new Proxy(this.cleanAttributes(data.attributes || {}), this.handler);
|
|
778
|
+
delete this._data.attributes;
|
|
779
|
+
if (davService) {
|
|
780
|
+
this._knownDavService = davService;
|
|
781
|
+
}
|
|
608
782
|
}
|
|
609
783
|
/**
|
|
610
784
|
* Get the source url to this object
|
|
785
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
786
|
+
* You can use the rename or move method to change the source.
|
|
611
787
|
*/
|
|
612
788
|
get source() {
|
|
613
789
|
return this._data.source.replace(/\/$/i, "");
|
|
@@ -616,49 +792,63 @@ class Q {
|
|
|
616
792
|
* Get the encoded source url to this object for requests purposes
|
|
617
793
|
*/
|
|
618
794
|
get encodedSource() {
|
|
619
|
-
const { origin
|
|
620
|
-
return
|
|
795
|
+
const { origin } = new URL(this.source);
|
|
796
|
+
return origin + encodePath(this.source.slice(origin.length));
|
|
621
797
|
}
|
|
622
798
|
/**
|
|
623
799
|
* Get this object name
|
|
800
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
801
|
+
* You can use the rename or move method to change the source.
|
|
624
802
|
*/
|
|
625
803
|
get basename() {
|
|
626
|
-
return
|
|
804
|
+
return basename(this.source);
|
|
627
805
|
}
|
|
628
806
|
/**
|
|
629
807
|
* Get this object's extension
|
|
808
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
809
|
+
* You can use the rename or move method to change the source.
|
|
630
810
|
*/
|
|
631
811
|
get extension() {
|
|
632
|
-
return
|
|
812
|
+
return extname(this.source);
|
|
633
813
|
}
|
|
634
814
|
/**
|
|
635
815
|
* Get the directory path leading to this object
|
|
636
816
|
* Will use the relative path to root if available
|
|
817
|
+
*
|
|
818
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
819
|
+
* You can use the rename or move method to change the source.
|
|
637
820
|
*/
|
|
638
821
|
get dirname() {
|
|
639
822
|
if (this.root) {
|
|
640
|
-
let
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
823
|
+
let source = this.source;
|
|
824
|
+
if (this.isDavRessource) {
|
|
825
|
+
source = source.split(this._knownDavService).pop();
|
|
826
|
+
}
|
|
827
|
+
const firstMatch = source.indexOf(this.root);
|
|
828
|
+
const root = this.root.replace(/\/$/, "");
|
|
829
|
+
return dirname(source.slice(firstMatch + root.length) || "/");
|
|
644
830
|
}
|
|
645
|
-
const
|
|
646
|
-
return
|
|
831
|
+
const url = new URL(this.source);
|
|
832
|
+
return dirname(url.pathname);
|
|
647
833
|
}
|
|
648
834
|
/**
|
|
649
835
|
* Get the file mime
|
|
836
|
+
* There is no setter as the mime is not meant to be changed
|
|
650
837
|
*/
|
|
651
838
|
get mime() {
|
|
652
839
|
return this._data.mime;
|
|
653
840
|
}
|
|
654
841
|
/**
|
|
655
842
|
* Get the file modification time
|
|
843
|
+
* There is no setter as the modification time is not meant to be changed manually.
|
|
844
|
+
* It will be automatically updated when the attributes are changed.
|
|
656
845
|
*/
|
|
657
846
|
get mtime() {
|
|
658
847
|
return this._data.mtime;
|
|
659
848
|
}
|
|
660
849
|
/**
|
|
661
850
|
* Get the file creation time
|
|
851
|
+
* There is no setter as the creation time is not meant to be changed
|
|
662
852
|
*/
|
|
663
853
|
get crtime() {
|
|
664
854
|
return this._data.crtime;
|
|
@@ -669,6 +859,13 @@ class Q {
|
|
|
669
859
|
get size() {
|
|
670
860
|
return this._data.size;
|
|
671
861
|
}
|
|
862
|
+
/**
|
|
863
|
+
* Set the file size
|
|
864
|
+
*/
|
|
865
|
+
set size(size) {
|
|
866
|
+
this.updateMtime();
|
|
867
|
+
this._data.size = size;
|
|
868
|
+
}
|
|
672
869
|
/**
|
|
673
870
|
* Get the file attribute
|
|
674
871
|
*/
|
|
@@ -679,44 +876,69 @@ class Q {
|
|
|
679
876
|
* Get the file permissions
|
|
680
877
|
*/
|
|
681
878
|
get permissions() {
|
|
682
|
-
|
|
879
|
+
if (this.owner === null && !this.isDavRessource) {
|
|
880
|
+
return Permission.READ;
|
|
881
|
+
}
|
|
882
|
+
return this._data.permissions !== void 0 ? this._data.permissions : Permission.NONE;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Set the file permissions
|
|
886
|
+
*/
|
|
887
|
+
set permissions(permissions) {
|
|
888
|
+
this.updateMtime();
|
|
889
|
+
this._data.permissions = permissions;
|
|
683
890
|
}
|
|
684
891
|
/**
|
|
685
892
|
* Get the file owner
|
|
893
|
+
* There is no setter as the owner is not meant to be changed
|
|
686
894
|
*/
|
|
687
895
|
get owner() {
|
|
688
|
-
|
|
896
|
+
if (!this.isDavRessource) {
|
|
897
|
+
return null;
|
|
898
|
+
}
|
|
899
|
+
return this._data.owner;
|
|
689
900
|
}
|
|
690
901
|
/**
|
|
691
902
|
* Is this a dav-related ressource ?
|
|
692
903
|
*/
|
|
693
904
|
get isDavRessource() {
|
|
694
|
-
return
|
|
905
|
+
return isDavRessource(this.source, this._knownDavService);
|
|
695
906
|
}
|
|
696
907
|
/**
|
|
697
908
|
* Get the dav root of this object
|
|
909
|
+
* There is no setter as the root is not meant to be changed
|
|
698
910
|
*/
|
|
699
911
|
get root() {
|
|
700
|
-
|
|
912
|
+
if (this._data.root) {
|
|
913
|
+
return this._data.root.replace(/^(.+)\/$/, "$1");
|
|
914
|
+
}
|
|
915
|
+
if (this.isDavRessource) {
|
|
916
|
+
const root = dirname(this.source);
|
|
917
|
+
return root.split(this._knownDavService).pop() || null;
|
|
918
|
+
}
|
|
919
|
+
return null;
|
|
701
920
|
}
|
|
702
921
|
/**
|
|
703
922
|
* Get the absolute path of this object relative to the root
|
|
704
923
|
*/
|
|
705
924
|
get path() {
|
|
706
925
|
if (this.root) {
|
|
707
|
-
let
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
926
|
+
let source = this.source;
|
|
927
|
+
if (this.isDavRessource) {
|
|
928
|
+
source = source.split(this._knownDavService).pop();
|
|
929
|
+
}
|
|
930
|
+
const firstMatch = source.indexOf(this.root);
|
|
931
|
+
const root = this.root.replace(/\/$/, "");
|
|
932
|
+
return source.slice(firstMatch + root.length) || "/";
|
|
711
933
|
}
|
|
712
934
|
return (this.dirname + "/" + this.basename).replace(/\/\//g, "/");
|
|
713
935
|
}
|
|
714
936
|
/**
|
|
715
937
|
* Get the node id if defined.
|
|
716
|
-
*
|
|
938
|
+
* There is no setter as the fileid is not meant to be changed
|
|
717
939
|
*/
|
|
718
940
|
get fileid() {
|
|
719
|
-
return this._data?.id
|
|
941
|
+
return this._data?.id;
|
|
720
942
|
}
|
|
721
943
|
/**
|
|
722
944
|
* Get the node status.
|
|
@@ -727,8 +949,8 @@ class Q {
|
|
|
727
949
|
/**
|
|
728
950
|
* Set the node status.
|
|
729
951
|
*/
|
|
730
|
-
set status(
|
|
731
|
-
this._data.status =
|
|
952
|
+
set status(status) {
|
|
953
|
+
this._data.status = status;
|
|
732
954
|
}
|
|
733
955
|
/**
|
|
734
956
|
* Move the node to a new destination
|
|
@@ -736,8 +958,10 @@ class Q {
|
|
|
736
958
|
* @param {string} destination the new source.
|
|
737
959
|
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
738
960
|
*/
|
|
739
|
-
move(
|
|
740
|
-
|
|
961
|
+
move(destination) {
|
|
962
|
+
validateData({ ...this._data, source: destination }, this._knownDavService);
|
|
963
|
+
this._data.source = destination;
|
|
964
|
+
this.updateMtime();
|
|
741
965
|
}
|
|
742
966
|
/**
|
|
743
967
|
* Rename the node
|
|
@@ -745,16 +969,39 @@ class Q {
|
|
|
745
969
|
*
|
|
746
970
|
* @param basename The new name of the node
|
|
747
971
|
*/
|
|
748
|
-
rename(
|
|
749
|
-
if (
|
|
972
|
+
rename(basename2) {
|
|
973
|
+
if (basename2.includes("/")) {
|
|
750
974
|
throw new Error("Invalid basename");
|
|
751
|
-
|
|
975
|
+
}
|
|
976
|
+
this.move(dirname(this.source) + "/" + basename2);
|
|
752
977
|
}
|
|
753
978
|
/**
|
|
754
979
|
* Update the mtime if exists.
|
|
755
980
|
*/
|
|
756
981
|
updateMtime() {
|
|
757
|
-
|
|
982
|
+
if (this._data.mtime) {
|
|
983
|
+
this._data.mtime = /* @__PURE__ */ new Date();
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Update the attributes of the node
|
|
988
|
+
*
|
|
989
|
+
* @param attributes The new attributes to update
|
|
990
|
+
*/
|
|
991
|
+
update(attributes) {
|
|
992
|
+
this._attributes = new Proxy(this.cleanAttributes(attributes), this.handler);
|
|
993
|
+
}
|
|
994
|
+
cleanAttributes(attributes) {
|
|
995
|
+
const getters = Object.entries(Object.getOwnPropertyDescriptors(Node.prototype)).filter((e) => typeof e[1].get === "function" && e[0] !== "__proto__").map((e) => e[0]);
|
|
996
|
+
const clean = {};
|
|
997
|
+
for (const key in attributes) {
|
|
998
|
+
if (getters.includes(key)) {
|
|
999
|
+
logger.debug(`Discarding protected attribute ${key}`, { node: this, attributes });
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
clean[key] = attributes[key];
|
|
1003
|
+
}
|
|
1004
|
+
return clean;
|
|
758
1005
|
}
|
|
759
1006
|
}
|
|
760
1007
|
/**
|
|
@@ -778,9 +1025,9 @@ class Q {
|
|
|
778
1025
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
779
1026
|
*
|
|
780
1027
|
*/
|
|
781
|
-
class
|
|
1028
|
+
class File extends Node {
|
|
782
1029
|
get type() {
|
|
783
|
-
return
|
|
1030
|
+
return FileType.File;
|
|
784
1031
|
}
|
|
785
1032
|
}
|
|
786
1033
|
/**
|
|
@@ -804,15 +1051,15 @@ class _e extends Q {
|
|
|
804
1051
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
805
1052
|
*
|
|
806
1053
|
*/
|
|
807
|
-
class
|
|
808
|
-
constructor(
|
|
1054
|
+
class Folder extends Node {
|
|
1055
|
+
constructor(data) {
|
|
809
1056
|
super({
|
|
810
|
-
...
|
|
1057
|
+
...data,
|
|
811
1058
|
mime: "httpd/unix-directory"
|
|
812
1059
|
});
|
|
813
1060
|
}
|
|
814
1061
|
get type() {
|
|
815
|
-
return
|
|
1062
|
+
return FileType.Folder;
|
|
816
1063
|
}
|
|
817
1064
|
get extension() {
|
|
818
1065
|
return null;
|
|
@@ -843,62 +1090,95 @@ class ve extends Q {
|
|
|
843
1090
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
844
1091
|
*
|
|
845
1092
|
*/
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
1093
|
+
const davRootPath = `/files/${getCurrentUser()?.uid}`;
|
|
1094
|
+
const davRemoteURL = generateRemoteUrl("dav");
|
|
1095
|
+
const davGetClient = function(remoteURL = davRemoteURL, headers = {}) {
|
|
1096
|
+
const client = createClient(remoteURL, { headers });
|
|
1097
|
+
function setHeaders(token) {
|
|
1098
|
+
client.setHeaders({
|
|
1099
|
+
...headers,
|
|
851
1100
|
// Add this so the server knows it is an request from the browser
|
|
852
1101
|
"X-Requested-With": "XMLHttpRequest",
|
|
853
1102
|
// Inject user auth
|
|
854
|
-
requesttoken:
|
|
1103
|
+
requesttoken: token ?? ""
|
|
855
1104
|
});
|
|
856
1105
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
1106
|
+
onRequestTokenUpdate(setHeaders);
|
|
1107
|
+
setHeaders(getRequestToken());
|
|
1108
|
+
const patcher = getPatcher();
|
|
1109
|
+
patcher.patch("fetch", (url, options) => {
|
|
1110
|
+
const headers2 = options.headers;
|
|
1111
|
+
if (headers2?.method) {
|
|
1112
|
+
options.method = headers2.method;
|
|
1113
|
+
delete headers2.method;
|
|
1114
|
+
}
|
|
1115
|
+
return fetch(url, options);
|
|
1116
|
+
});
|
|
1117
|
+
return client;
|
|
1118
|
+
};
|
|
1119
|
+
const getFavoriteNodes = (davClient, path = "/", davRoot = davRootPath) => {
|
|
1120
|
+
const controller = new AbortController();
|
|
1121
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
1122
|
+
onCancel(() => controller.abort());
|
|
865
1123
|
try {
|
|
866
|
-
const
|
|
867
|
-
signal:
|
|
868
|
-
details:
|
|
869
|
-
data:
|
|
1124
|
+
const contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {
|
|
1125
|
+
signal: controller.signal,
|
|
1126
|
+
details: true,
|
|
1127
|
+
data: davGetFavoritesReport(),
|
|
870
1128
|
headers: {
|
|
871
1129
|
// see davGetClient for patched webdav client
|
|
872
1130
|
method: "REPORT"
|
|
873
1131
|
},
|
|
874
|
-
includeSelf:
|
|
875
|
-
})
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1132
|
+
includeSelf: true
|
|
1133
|
+
});
|
|
1134
|
+
const nodes = contentsResponse.data.filter((node) => node.filename !== path).map((result) => davResultToNode(result, davRoot));
|
|
1135
|
+
resolve(nodes);
|
|
1136
|
+
} catch (error) {
|
|
1137
|
+
reject(error);
|
|
879
1138
|
}
|
|
880
1139
|
});
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
|
|
1140
|
+
};
|
|
1141
|
+
const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davRemoteURL) {
|
|
1142
|
+
let userId = getCurrentUser()?.uid;
|
|
1143
|
+
const isPublic = document.querySelector("input#isPublic")?.value;
|
|
1144
|
+
if (isPublic) {
|
|
1145
|
+
userId = userId ?? document.querySelector("input#sharingUserId")?.value;
|
|
1146
|
+
userId = userId ?? "anonymous";
|
|
1147
|
+
} else if (!userId) {
|
|
884
1148
|
throw new Error("No user id found");
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1149
|
+
}
|
|
1150
|
+
const props = node.props;
|
|
1151
|
+
const permissions = davParsePermissions(props?.permissions);
|
|
1152
|
+
const owner = String(props?.["owner-id"] || userId);
|
|
1153
|
+
const nodeData = {
|
|
1154
|
+
id: props?.fileid || 0,
|
|
1155
|
+
source: `${remoteURL}${node.filename}`,
|
|
1156
|
+
mtime: new Date(Date.parse(node.lastmod)),
|
|
1157
|
+
mime: node.mime || "application/octet-stream",
|
|
1158
|
+
size: props?.size || Number.parseInt(props.getcontentlength || "0"),
|
|
1159
|
+
permissions,
|
|
1160
|
+
owner,
|
|
1161
|
+
root: filesRoot,
|
|
894
1162
|
attributes: {
|
|
895
|
-
...
|
|
896
|
-
...
|
|
897
|
-
hasPreview:
|
|
1163
|
+
...node,
|
|
1164
|
+
...props,
|
|
1165
|
+
hasPreview: props?.["has-preview"]
|
|
898
1166
|
}
|
|
899
1167
|
};
|
|
900
|
-
|
|
1168
|
+
delete nodeData.attributes?.props;
|
|
1169
|
+
return node.type === "file" ? new File(nodeData) : new Folder(nodeData);
|
|
901
1170
|
};
|
|
1171
|
+
const forbiddenCharacters = window._oc_config?.forbidden_filenames_characters ?? ["/", "\\"];
|
|
1172
|
+
const forbiddenFilenameRegex = window._oc_config?.blacklist_files_regex ? new RegExp(window._oc_config.blacklist_files_regex) : null;
|
|
1173
|
+
function isFilenameValid(filename) {
|
|
1174
|
+
if (forbiddenCharacters.some((character) => filename.includes(character))) {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
if (forbiddenFilenameRegex !== null && filename.match(forbiddenFilenameRegex)) {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
return true;
|
|
1181
|
+
}
|
|
902
1182
|
/**
|
|
903
1183
|
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
904
1184
|
*
|
|
@@ -920,30 +1200,37 @@ const D = `/files/${A()?.uid}`, ee = pe("dav"), ar = function(e = ee, t = {}) {
|
|
|
920
1200
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
921
1201
|
*
|
|
922
1202
|
*/
|
|
923
|
-
class
|
|
1203
|
+
class Navigation {
|
|
924
1204
|
_views = [];
|
|
925
1205
|
_currentView = null;
|
|
926
|
-
register(
|
|
927
|
-
if (this._views.find((
|
|
928
|
-
throw new Error(`View id ${
|
|
929
|
-
|
|
1206
|
+
register(view) {
|
|
1207
|
+
if (this._views.find((search) => search.id === view.id)) {
|
|
1208
|
+
throw new Error(`View id ${view.id} is already registered`);
|
|
1209
|
+
}
|
|
1210
|
+
this._views.push(view);
|
|
930
1211
|
}
|
|
931
|
-
remove(
|
|
932
|
-
const
|
|
933
|
-
|
|
1212
|
+
remove(id) {
|
|
1213
|
+
const index = this._views.findIndex((view) => view.id === id);
|
|
1214
|
+
if (index !== -1) {
|
|
1215
|
+
this._views.splice(index, 1);
|
|
1216
|
+
}
|
|
934
1217
|
}
|
|
935
1218
|
get views() {
|
|
936
1219
|
return this._views;
|
|
937
1220
|
}
|
|
938
|
-
setActive(
|
|
939
|
-
this._currentView =
|
|
1221
|
+
setActive(view) {
|
|
1222
|
+
this._currentView = view;
|
|
940
1223
|
}
|
|
941
1224
|
get active() {
|
|
942
1225
|
return this._currentView;
|
|
943
1226
|
}
|
|
944
1227
|
}
|
|
945
|
-
const
|
|
946
|
-
|
|
1228
|
+
const getNavigation = function() {
|
|
1229
|
+
if (typeof window._nc_navigation === "undefined") {
|
|
1230
|
+
window._nc_navigation = new Navigation();
|
|
1231
|
+
logger.debug("Navigation service initialized");
|
|
1232
|
+
}
|
|
1233
|
+
return window._nc_navigation;
|
|
947
1234
|
};
|
|
948
1235
|
/**
|
|
949
1236
|
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
@@ -966,10 +1253,11 @@ const fr = function() {
|
|
|
966
1253
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
967
1254
|
*
|
|
968
1255
|
*/
|
|
969
|
-
class
|
|
1256
|
+
class Column {
|
|
970
1257
|
_column;
|
|
971
|
-
constructor(
|
|
972
|
-
|
|
1258
|
+
constructor(column) {
|
|
1259
|
+
isValidColumn(column);
|
|
1260
|
+
this._column = column;
|
|
973
1261
|
}
|
|
974
1262
|
get id() {
|
|
975
1263
|
return this._column.id;
|
|
@@ -987,918 +1275,1437 @@ class Ae {
|
|
|
987
1275
|
return this._column.summary;
|
|
988
1276
|
}
|
|
989
1277
|
}
|
|
990
|
-
const
|
|
991
|
-
if (!
|
|
1278
|
+
const isValidColumn = function(column) {
|
|
1279
|
+
if (!column.id || typeof column.id !== "string") {
|
|
992
1280
|
throw new Error("A column id is required");
|
|
993
|
-
|
|
1281
|
+
}
|
|
1282
|
+
if (!column.title || typeof column.title !== "string") {
|
|
994
1283
|
throw new Error("A column title is required");
|
|
995
|
-
|
|
1284
|
+
}
|
|
1285
|
+
if (!column.render || typeof column.render !== "function") {
|
|
996
1286
|
throw new Error("A render function is required");
|
|
997
|
-
|
|
1287
|
+
}
|
|
1288
|
+
if (column.sort && typeof column.sort !== "function") {
|
|
998
1289
|
throw new Error("Column sortFunction must be a function");
|
|
999
|
-
|
|
1290
|
+
}
|
|
1291
|
+
if (column.summary && typeof column.summary !== "function") {
|
|
1000
1292
|
throw new Error("Column summary must be a function");
|
|
1001
|
-
|
|
1293
|
+
}
|
|
1294
|
+
return true;
|
|
1002
1295
|
};
|
|
1003
|
-
var
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1296
|
+
var validator$2 = {};
|
|
1297
|
+
var util$3 = {};
|
|
1298
|
+
(function(exports) {
|
|
1299
|
+
const nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
1300
|
+
const nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
1301
|
+
const nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
|
|
1302
|
+
const regexName = new RegExp("^" + nameRegexp + "$");
|
|
1303
|
+
const getAllMatches = function(string, regex) {
|
|
1304
|
+
const matches = [];
|
|
1305
|
+
let match = regex.exec(string);
|
|
1306
|
+
while (match) {
|
|
1307
|
+
const allmatches = [];
|
|
1308
|
+
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
1309
|
+
const len = match.length;
|
|
1310
|
+
for (let index = 0; index < len; index++) {
|
|
1311
|
+
allmatches.push(match[index]);
|
|
1312
|
+
}
|
|
1313
|
+
matches.push(allmatches);
|
|
1314
|
+
match = regex.exec(string);
|
|
1015
1315
|
}
|
|
1016
|
-
return
|
|
1017
|
-
}, d = function(u) {
|
|
1018
|
-
const o = n.exec(u);
|
|
1019
|
-
return !(o === null || typeof o > "u");
|
|
1316
|
+
return matches;
|
|
1020
1317
|
};
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1318
|
+
const isName = function(string) {
|
|
1319
|
+
const match = regexName.exec(string);
|
|
1320
|
+
return !(match === null || typeof match === "undefined");
|
|
1321
|
+
};
|
|
1322
|
+
exports.isExist = function(v) {
|
|
1323
|
+
return typeof v !== "undefined";
|
|
1324
|
+
};
|
|
1325
|
+
exports.isEmptyObject = function(obj) {
|
|
1326
|
+
return Object.keys(obj).length === 0;
|
|
1327
|
+
};
|
|
1328
|
+
exports.merge = function(target, a, arrayMode) {
|
|
1329
|
+
if (a) {
|
|
1330
|
+
const keys = Object.keys(a);
|
|
1331
|
+
const len = keys.length;
|
|
1332
|
+
for (let i = 0; i < len; i++) {
|
|
1333
|
+
if (arrayMode === "strict") {
|
|
1334
|
+
target[keys[i]] = [a[keys[i]]];
|
|
1335
|
+
} else {
|
|
1336
|
+
target[keys[i]] = a[keys[i]];
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
exports.getValue = function(v) {
|
|
1342
|
+
if (exports.isExist(v)) {
|
|
1343
|
+
return v;
|
|
1344
|
+
} else {
|
|
1345
|
+
return "";
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
exports.isName = isName;
|
|
1349
|
+
exports.getAllMatches = getAllMatches;
|
|
1350
|
+
exports.nameRegexp = nameRegexp;
|
|
1351
|
+
})(util$3);
|
|
1352
|
+
const util$2 = util$3;
|
|
1353
|
+
const defaultOptions$2 = {
|
|
1354
|
+
allowBooleanAttributes: false,
|
|
1037
1355
|
//A tag can have attributes without any value
|
|
1038
1356
|
unpairedTags: []
|
|
1039
1357
|
};
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
const
|
|
1043
|
-
let
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1358
|
+
validator$2.validate = function(xmlData, options) {
|
|
1359
|
+
options = Object.assign({}, defaultOptions$2, options);
|
|
1360
|
+
const tags = [];
|
|
1361
|
+
let tagFound = false;
|
|
1362
|
+
let reachedRoot = false;
|
|
1363
|
+
if (xmlData[0] === "\uFEFF") {
|
|
1364
|
+
xmlData = xmlData.substr(1);
|
|
1365
|
+
}
|
|
1366
|
+
for (let i = 0; i < xmlData.length; i++) {
|
|
1367
|
+
if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
|
|
1368
|
+
i += 2;
|
|
1369
|
+
i = readPI(xmlData, i);
|
|
1370
|
+
if (i.err)
|
|
1048
1371
|
return i;
|
|
1049
|
-
} else if (
|
|
1050
|
-
let
|
|
1051
|
-
|
|
1052
|
-
|
|
1372
|
+
} else if (xmlData[i] === "<") {
|
|
1373
|
+
let tagStartPos = i;
|
|
1374
|
+
i++;
|
|
1375
|
+
if (xmlData[i] === "!") {
|
|
1376
|
+
i = readCommentAndCDATA(xmlData, i);
|
|
1053
1377
|
continue;
|
|
1054
1378
|
} else {
|
|
1055
|
-
let
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
` && e[i] !== "\r"; i++)
|
|
1060
|
-
o += e[i];
|
|
1061
|
-
if (o = o.trim(), o[o.length - 1] === "/" && (o = o.substring(0, o.length - 1), i--), !Re(o)) {
|
|
1062
|
-
let f;
|
|
1063
|
-
return o.trim().length === 0 ? f = "Invalid space after '<'." : f = "Tag '" + o + "' is an invalid name.", p("InvalidTag", f, w(e, i));
|
|
1379
|
+
let closingTag = false;
|
|
1380
|
+
if (xmlData[i] === "/") {
|
|
1381
|
+
closingTag = true;
|
|
1382
|
+
i++;
|
|
1064
1383
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1384
|
+
let tagName = "";
|
|
1385
|
+
for (; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++) {
|
|
1386
|
+
tagName += xmlData[i];
|
|
1387
|
+
}
|
|
1388
|
+
tagName = tagName.trim();
|
|
1389
|
+
if (tagName[tagName.length - 1] === "/") {
|
|
1390
|
+
tagName = tagName.substring(0, tagName.length - 1);
|
|
1391
|
+
i--;
|
|
1392
|
+
}
|
|
1393
|
+
if (!validateTagName(tagName)) {
|
|
1394
|
+
let msg;
|
|
1395
|
+
if (tagName.trim().length === 0) {
|
|
1396
|
+
msg = "Invalid space after '<'.";
|
|
1397
|
+
} else {
|
|
1398
|
+
msg = "Tag '" + tagName + "' is an invalid name.";
|
|
1399
|
+
}
|
|
1400
|
+
return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
|
|
1401
|
+
}
|
|
1402
|
+
const result = readAttributeStr(xmlData, i);
|
|
1403
|
+
if (result === false) {
|
|
1404
|
+
return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
|
|
1405
|
+
}
|
|
1406
|
+
let attrStr = result.value;
|
|
1407
|
+
i = result.index;
|
|
1408
|
+
if (attrStr[attrStr.length - 1] === "/") {
|
|
1409
|
+
const attrStrStart = i - attrStr.length;
|
|
1410
|
+
attrStr = attrStr.substring(0, attrStr.length - 1);
|
|
1411
|
+
const isValid = validateAttributeString(attrStr, options);
|
|
1412
|
+
if (isValid === true) {
|
|
1413
|
+
tagFound = true;
|
|
1414
|
+
} else {
|
|
1415
|
+
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
|
|
1416
|
+
}
|
|
1417
|
+
} else if (closingTag) {
|
|
1418
|
+
if (!result.tagClosed) {
|
|
1419
|
+
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
|
|
1420
|
+
} else if (attrStr.trim().length > 0) {
|
|
1421
|
+
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
1422
|
+
} else {
|
|
1423
|
+
const otg = tags.pop();
|
|
1424
|
+
if (tagName !== otg.tagName) {
|
|
1425
|
+
let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
|
|
1426
|
+
return getErrorObject(
|
|
1427
|
+
"InvalidTag",
|
|
1428
|
+
"Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
|
|
1429
|
+
getLineNumberForPosition(xmlData, tagStartPos)
|
|
1430
|
+
);
|
|
1092
1431
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
if (
|
|
1100
|
-
return
|
|
1101
|
-
|
|
1432
|
+
if (tags.length == 0) {
|
|
1433
|
+
reachedRoot = true;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
} else {
|
|
1437
|
+
const isValid = validateAttributeString(attrStr, options);
|
|
1438
|
+
if (isValid !== true) {
|
|
1439
|
+
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
|
|
1440
|
+
}
|
|
1441
|
+
if (reachedRoot === true) {
|
|
1442
|
+
return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
|
|
1443
|
+
} else if (options.unpairedTags.indexOf(tagName) !== -1)
|
|
1444
|
+
;
|
|
1445
|
+
else {
|
|
1446
|
+
tags.push({ tagName, tagStartPos });
|
|
1447
|
+
}
|
|
1448
|
+
tagFound = true;
|
|
1102
1449
|
}
|
|
1103
|
-
for (i++; i <
|
|
1104
|
-
if (
|
|
1105
|
-
if (
|
|
1106
|
-
i
|
|
1450
|
+
for (i++; i < xmlData.length; i++) {
|
|
1451
|
+
if (xmlData[i] === "<") {
|
|
1452
|
+
if (xmlData[i + 1] === "!") {
|
|
1453
|
+
i++;
|
|
1454
|
+
i = readCommentAndCDATA(xmlData, i);
|
|
1107
1455
|
continue;
|
|
1108
|
-
} else if (
|
|
1109
|
-
|
|
1456
|
+
} else if (xmlData[i + 1] === "?") {
|
|
1457
|
+
i = readPI(xmlData, ++i);
|
|
1458
|
+
if (i.err)
|
|
1110
1459
|
return i;
|
|
1111
|
-
} else
|
|
1460
|
+
} else {
|
|
1112
1461
|
break;
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1462
|
+
}
|
|
1463
|
+
} else if (xmlData[i] === "&") {
|
|
1464
|
+
const afterAmp = validateAmpersand(xmlData, i);
|
|
1465
|
+
if (afterAmp == -1)
|
|
1466
|
+
return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
|
|
1467
|
+
i = afterAmp;
|
|
1468
|
+
} else {
|
|
1469
|
+
if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
|
|
1470
|
+
return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
if (xmlData[i] === "<") {
|
|
1475
|
+
i--;
|
|
1476
|
+
}
|
|
1121
1477
|
}
|
|
1122
1478
|
} else {
|
|
1123
|
-
if (
|
|
1479
|
+
if (isWhiteSpace(xmlData[i])) {
|
|
1124
1480
|
continue;
|
|
1125
|
-
|
|
1481
|
+
}
|
|
1482
|
+
return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
|
|
1126
1483
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
} else
|
|
1133
|
-
return
|
|
1134
|
-
|
|
1484
|
+
}
|
|
1485
|
+
if (!tagFound) {
|
|
1486
|
+
return getErrorObject("InvalidXml", "Start tag expected.", 1);
|
|
1487
|
+
} else if (tags.length == 1) {
|
|
1488
|
+
return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
|
|
1489
|
+
} else if (tags.length > 0) {
|
|
1490
|
+
return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
1491
|
+
}
|
|
1492
|
+
return true;
|
|
1135
1493
|
};
|
|
1136
|
-
function
|
|
1137
|
-
return
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
t++;
|
|
1494
|
+
function isWhiteSpace(char) {
|
|
1495
|
+
return char === " " || char === " " || char === "\n" || char === "\r";
|
|
1496
|
+
}
|
|
1497
|
+
function readPI(xmlData, i) {
|
|
1498
|
+
const start = i;
|
|
1499
|
+
for (; i < xmlData.length; i++) {
|
|
1500
|
+
if (xmlData[i] == "?" || xmlData[i] == " ") {
|
|
1501
|
+
const tagname = xmlData.substr(start, i - start);
|
|
1502
|
+
if (i > 5 && tagname === "xml") {
|
|
1503
|
+
return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
|
|
1504
|
+
} else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
|
|
1505
|
+
i++;
|
|
1149
1506
|
break;
|
|
1150
|
-
} else
|
|
1507
|
+
} else {
|
|
1151
1508
|
continue;
|
|
1509
|
+
}
|
|
1152
1510
|
}
|
|
1153
|
-
|
|
1511
|
+
}
|
|
1512
|
+
return i;
|
|
1154
1513
|
}
|
|
1155
|
-
function
|
|
1156
|
-
if (
|
|
1157
|
-
for (
|
|
1158
|
-
if (
|
|
1159
|
-
|
|
1514
|
+
function readCommentAndCDATA(xmlData, i) {
|
|
1515
|
+
if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
|
|
1516
|
+
for (i += 3; i < xmlData.length; i++) {
|
|
1517
|
+
if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
|
|
1518
|
+
i += 2;
|
|
1160
1519
|
break;
|
|
1161
1520
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1521
|
+
}
|
|
1522
|
+
} else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
|
|
1523
|
+
let angleBracketsCount = 1;
|
|
1524
|
+
for (i += 8; i < xmlData.length; i++) {
|
|
1525
|
+
if (xmlData[i] === "<") {
|
|
1526
|
+
angleBracketsCount++;
|
|
1527
|
+
} else if (xmlData[i] === ">") {
|
|
1528
|
+
angleBracketsCount--;
|
|
1529
|
+
if (angleBracketsCount === 0) {
|
|
1530
|
+
break;
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
} else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
|
|
1535
|
+
for (i += 8; i < xmlData.length; i++) {
|
|
1536
|
+
if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
|
|
1537
|
+
i += 2;
|
|
1173
1538
|
break;
|
|
1174
1539
|
}
|
|
1540
|
+
}
|
|
1175
1541
|
}
|
|
1176
|
-
return
|
|
1542
|
+
return i;
|
|
1177
1543
|
}
|
|
1178
|
-
const
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1544
|
+
const doubleQuote = '"';
|
|
1545
|
+
const singleQuote = "'";
|
|
1546
|
+
function readAttributeStr(xmlData, i) {
|
|
1547
|
+
let attrStr = "";
|
|
1548
|
+
let startChar = "";
|
|
1549
|
+
let tagClosed = false;
|
|
1550
|
+
for (; i < xmlData.length; i++) {
|
|
1551
|
+
if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
|
|
1552
|
+
if (startChar === "") {
|
|
1553
|
+
startChar = xmlData[i];
|
|
1554
|
+
} else if (startChar !== xmlData[i])
|
|
1555
|
+
;
|
|
1556
|
+
else {
|
|
1557
|
+
startChar = "";
|
|
1558
|
+
}
|
|
1559
|
+
} else if (xmlData[i] === ">") {
|
|
1560
|
+
if (startChar === "") {
|
|
1561
|
+
tagClosed = true;
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1187
1564
|
}
|
|
1188
|
-
|
|
1565
|
+
attrStr += xmlData[i];
|
|
1189
1566
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1567
|
+
if (startChar !== "") {
|
|
1568
|
+
return false;
|
|
1569
|
+
}
|
|
1570
|
+
return {
|
|
1571
|
+
value: attrStr,
|
|
1572
|
+
index: i,
|
|
1573
|
+
tagClosed
|
|
1194
1574
|
};
|
|
1195
1575
|
}
|
|
1196
|
-
const
|
|
1197
|
-
function
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
if (!
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1576
|
+
const validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
1577
|
+
function validateAttributeString(attrStr, options) {
|
|
1578
|
+
const matches = util$2.getAllMatches(attrStr, validAttrStrRegxp);
|
|
1579
|
+
const attrNames = {};
|
|
1580
|
+
for (let i = 0; i < matches.length; i++) {
|
|
1581
|
+
if (matches[i][1].length === 0) {
|
|
1582
|
+
return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
|
|
1583
|
+
} else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
|
|
1584
|
+
return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
|
|
1585
|
+
} else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
|
|
1586
|
+
return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
|
|
1587
|
+
}
|
|
1588
|
+
const attrName = matches[i][2];
|
|
1589
|
+
if (!validateAttrName(attrName)) {
|
|
1590
|
+
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
|
|
1591
|
+
}
|
|
1592
|
+
if (!attrNames.hasOwnProperty(attrName)) {
|
|
1593
|
+
attrNames[attrName] = 1;
|
|
1594
|
+
} else {
|
|
1595
|
+
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
|
|
1596
|
+
}
|
|
1213
1597
|
}
|
|
1214
|
-
return
|
|
1598
|
+
return true;
|
|
1215
1599
|
}
|
|
1216
|
-
function
|
|
1217
|
-
let
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1600
|
+
function validateNumberAmpersand(xmlData, i) {
|
|
1601
|
+
let re = /\d/;
|
|
1602
|
+
if (xmlData[i] === "x") {
|
|
1603
|
+
i++;
|
|
1604
|
+
re = /[\da-fA-F]/;
|
|
1605
|
+
}
|
|
1606
|
+
for (; i < xmlData.length; i++) {
|
|
1607
|
+
if (xmlData[i] === ";")
|
|
1608
|
+
return i;
|
|
1609
|
+
if (!xmlData[i].match(re))
|
|
1222
1610
|
break;
|
|
1223
1611
|
}
|
|
1224
1612
|
return -1;
|
|
1225
1613
|
}
|
|
1226
|
-
function
|
|
1227
|
-
|
|
1614
|
+
function validateAmpersand(xmlData, i) {
|
|
1615
|
+
i++;
|
|
1616
|
+
if (xmlData[i] === ";")
|
|
1228
1617
|
return -1;
|
|
1229
|
-
if (
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1618
|
+
if (xmlData[i] === "#") {
|
|
1619
|
+
i++;
|
|
1620
|
+
return validateNumberAmpersand(xmlData, i);
|
|
1621
|
+
}
|
|
1622
|
+
let count = 0;
|
|
1623
|
+
for (; i < xmlData.length; i++, count++) {
|
|
1624
|
+
if (xmlData[i].match(/\w/) && count < 20)
|
|
1625
|
+
continue;
|
|
1626
|
+
if (xmlData[i] === ";")
|
|
1627
|
+
break;
|
|
1628
|
+
return -1;
|
|
1629
|
+
}
|
|
1630
|
+
return i;
|
|
1239
1631
|
}
|
|
1240
|
-
function
|
|
1632
|
+
function getErrorObject(code, message, lineNumber) {
|
|
1241
1633
|
return {
|
|
1242
1634
|
err: {
|
|
1243
|
-
code
|
|
1244
|
-
msg:
|
|
1245
|
-
line:
|
|
1246
|
-
col:
|
|
1635
|
+
code,
|
|
1636
|
+
msg: message,
|
|
1637
|
+
line: lineNumber.line || lineNumber,
|
|
1638
|
+
col: lineNumber.col
|
|
1247
1639
|
}
|
|
1248
1640
|
};
|
|
1249
1641
|
}
|
|
1250
|
-
function
|
|
1251
|
-
return
|
|
1642
|
+
function validateAttrName(attrName) {
|
|
1643
|
+
return util$2.isName(attrName);
|
|
1252
1644
|
}
|
|
1253
|
-
function
|
|
1254
|
-
return
|
|
1645
|
+
function validateTagName(tagname) {
|
|
1646
|
+
return util$2.isName(tagname);
|
|
1255
1647
|
}
|
|
1256
|
-
function
|
|
1257
|
-
const
|
|
1648
|
+
function getLineNumberForPosition(xmlData, index) {
|
|
1649
|
+
const lines = xmlData.substring(0, index).split(/\r?\n/);
|
|
1258
1650
|
return {
|
|
1259
|
-
line:
|
|
1651
|
+
line: lines.length,
|
|
1260
1652
|
// column number is last line's length + 1, because column numbering starts at 1:
|
|
1261
|
-
col:
|
|
1653
|
+
col: lines[lines.length - 1].length + 1
|
|
1262
1654
|
};
|
|
1263
1655
|
}
|
|
1264
|
-
function
|
|
1265
|
-
return
|
|
1656
|
+
function getPositionFromMatch(match) {
|
|
1657
|
+
return match.startIndex + match[1].length;
|
|
1266
1658
|
}
|
|
1267
|
-
var
|
|
1268
|
-
const
|
|
1269
|
-
preserveOrder:
|
|
1659
|
+
var OptionsBuilder = {};
|
|
1660
|
+
const defaultOptions$1 = {
|
|
1661
|
+
preserveOrder: false,
|
|
1270
1662
|
attributeNamePrefix: "@_",
|
|
1271
|
-
attributesGroupName:
|
|
1663
|
+
attributesGroupName: false,
|
|
1272
1664
|
textNodeName: "#text",
|
|
1273
|
-
ignoreAttributes:
|
|
1274
|
-
removeNSPrefix:
|
|
1665
|
+
ignoreAttributes: true,
|
|
1666
|
+
removeNSPrefix: false,
|
|
1275
1667
|
// remove NS from tag name or attribute name if true
|
|
1276
|
-
allowBooleanAttributes:
|
|
1668
|
+
allowBooleanAttributes: false,
|
|
1277
1669
|
//a tag can have attributes without any value
|
|
1278
1670
|
//ignoreRootElement : false,
|
|
1279
|
-
parseTagValue:
|
|
1280
|
-
parseAttributeValue:
|
|
1281
|
-
trimValues:
|
|
1671
|
+
parseTagValue: true,
|
|
1672
|
+
parseAttributeValue: false,
|
|
1673
|
+
trimValues: true,
|
|
1282
1674
|
//Trim string values of tag and attributes
|
|
1283
|
-
cdataPropName:
|
|
1675
|
+
cdataPropName: false,
|
|
1284
1676
|
numberParseOptions: {
|
|
1285
|
-
hex:
|
|
1286
|
-
leadingZeros:
|
|
1287
|
-
eNotation:
|
|
1677
|
+
hex: true,
|
|
1678
|
+
leadingZeros: true,
|
|
1679
|
+
eNotation: true
|
|
1288
1680
|
},
|
|
1289
|
-
tagValueProcessor: function(
|
|
1290
|
-
return
|
|
1681
|
+
tagValueProcessor: function(tagName, val2) {
|
|
1682
|
+
return val2;
|
|
1291
1683
|
},
|
|
1292
|
-
attributeValueProcessor: function(
|
|
1293
|
-
return
|
|
1684
|
+
attributeValueProcessor: function(attrName, val2) {
|
|
1685
|
+
return val2;
|
|
1294
1686
|
},
|
|
1295
1687
|
stopNodes: [],
|
|
1296
1688
|
//nested tags will not be parsed even for errors
|
|
1297
|
-
alwaysCreateTextNode:
|
|
1298
|
-
isArray: () =>
|
|
1299
|
-
commentPropName:
|
|
1689
|
+
alwaysCreateTextNode: false,
|
|
1690
|
+
isArray: () => false,
|
|
1691
|
+
commentPropName: false,
|
|
1300
1692
|
unpairedTags: [],
|
|
1301
|
-
processEntities:
|
|
1302
|
-
htmlEntities:
|
|
1303
|
-
ignoreDeclaration:
|
|
1304
|
-
ignorePiTags:
|
|
1305
|
-
transformTagName:
|
|
1306
|
-
transformAttributeName:
|
|
1307
|
-
updateTag: function(
|
|
1308
|
-
return
|
|
1693
|
+
processEntities: true,
|
|
1694
|
+
htmlEntities: false,
|
|
1695
|
+
ignoreDeclaration: false,
|
|
1696
|
+
ignorePiTags: false,
|
|
1697
|
+
transformTagName: false,
|
|
1698
|
+
transformAttributeName: false,
|
|
1699
|
+
updateTag: function(tagName, jPath, attrs) {
|
|
1700
|
+
return tagName;
|
|
1309
1701
|
}
|
|
1310
1702
|
// skipEmptyListItem: false
|
|
1311
|
-
}, Me = function(e) {
|
|
1312
|
-
return Object.assign({}, te, e);
|
|
1313
1703
|
};
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1704
|
+
const buildOptions$1 = function(options) {
|
|
1705
|
+
return Object.assign({}, defaultOptions$1, options);
|
|
1706
|
+
};
|
|
1707
|
+
OptionsBuilder.buildOptions = buildOptions$1;
|
|
1708
|
+
OptionsBuilder.defaultOptions = defaultOptions$1;
|
|
1709
|
+
class XmlNode {
|
|
1710
|
+
constructor(tagname) {
|
|
1711
|
+
this.tagname = tagname;
|
|
1712
|
+
this.child = [];
|
|
1713
|
+
this[":@"] = {};
|
|
1714
|
+
}
|
|
1715
|
+
add(key, val2) {
|
|
1716
|
+
if (key === "__proto__")
|
|
1717
|
+
key = "#__proto__";
|
|
1718
|
+
this.child.push({ [key]: val2 });
|
|
1719
|
+
}
|
|
1720
|
+
addChild(node) {
|
|
1721
|
+
if (node.tagname === "__proto__")
|
|
1722
|
+
node.tagname = "#__proto__";
|
|
1723
|
+
if (node[":@"] && Object.keys(node[":@"]).length > 0) {
|
|
1724
|
+
this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
|
|
1725
|
+
} else {
|
|
1726
|
+
this.child.push({ [node.tagname]: node.child });
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
var xmlNode$1 = XmlNode;
|
|
1731
|
+
const util$1 = util$3;
|
|
1732
|
+
function readDocType$1(xmlData, i) {
|
|
1733
|
+
const entities = {};
|
|
1734
|
+
if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
|
|
1735
|
+
i = i + 9;
|
|
1736
|
+
let angleBracketsCount = 1;
|
|
1737
|
+
let hasBody = false, comment = false;
|
|
1738
|
+
let exp = "";
|
|
1739
|
+
for (; i < xmlData.length; i++) {
|
|
1740
|
+
if (xmlData[i] === "<" && !comment) {
|
|
1741
|
+
if (hasBody && isEntity(xmlData, i)) {
|
|
1742
|
+
i += 7;
|
|
1743
|
+
[entityName, val, i] = readEntityExp(xmlData, i + 1);
|
|
1744
|
+
if (val.indexOf("&") === -1)
|
|
1745
|
+
entities[validateEntityName(entityName)] = {
|
|
1746
|
+
regx: RegExp(`&${entityName};`, "g"),
|
|
1747
|
+
val
|
|
1748
|
+
};
|
|
1749
|
+
} else if (hasBody && isElement(xmlData, i))
|
|
1750
|
+
i += 8;
|
|
1751
|
+
else if (hasBody && isAttlist(xmlData, i))
|
|
1752
|
+
i += 8;
|
|
1753
|
+
else if (hasBody && isNotation(xmlData, i))
|
|
1754
|
+
i += 9;
|
|
1755
|
+
else if (isComment)
|
|
1756
|
+
comment = true;
|
|
1349
1757
|
else
|
|
1350
1758
|
throw new Error("Invalid DOCTYPE");
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1759
|
+
angleBracketsCount++;
|
|
1760
|
+
exp = "";
|
|
1761
|
+
} else if (xmlData[i] === ">") {
|
|
1762
|
+
if (comment) {
|
|
1763
|
+
if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
|
|
1764
|
+
comment = false;
|
|
1765
|
+
angleBracketsCount--;
|
|
1766
|
+
}
|
|
1767
|
+
} else {
|
|
1768
|
+
angleBracketsCount--;
|
|
1769
|
+
}
|
|
1770
|
+
if (angleBracketsCount === 0) {
|
|
1354
1771
|
break;
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1772
|
+
}
|
|
1773
|
+
} else if (xmlData[i] === "[") {
|
|
1774
|
+
hasBody = true;
|
|
1775
|
+
} else {
|
|
1776
|
+
exp += xmlData[i];
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
if (angleBracketsCount !== 0) {
|
|
1780
|
+
throw new Error(`Unclosed DOCTYPE`);
|
|
1781
|
+
}
|
|
1782
|
+
} else {
|
|
1783
|
+
throw new Error(`Invalid Tag instead of DOCTYPE`);
|
|
1784
|
+
}
|
|
1785
|
+
return { entities, i };
|
|
1786
|
+
}
|
|
1787
|
+
function readEntityExp(xmlData, i) {
|
|
1788
|
+
let entityName2 = "";
|
|
1789
|
+
for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
|
|
1790
|
+
entityName2 += xmlData[i];
|
|
1791
|
+
}
|
|
1792
|
+
entityName2 = entityName2.trim();
|
|
1793
|
+
if (entityName2.indexOf(" ") !== -1)
|
|
1368
1794
|
throw new Error("External entites are not supported");
|
|
1369
|
-
const
|
|
1370
|
-
let
|
|
1371
|
-
for (;
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
return
|
|
1380
|
-
}
|
|
1381
|
-
function
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
!
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1795
|
+
const startChar = xmlData[i++];
|
|
1796
|
+
let val2 = "";
|
|
1797
|
+
for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
|
|
1798
|
+
val2 += xmlData[i];
|
|
1799
|
+
}
|
|
1800
|
+
return [entityName2, val2, i];
|
|
1801
|
+
}
|
|
1802
|
+
function isComment(xmlData, i) {
|
|
1803
|
+
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
|
|
1804
|
+
return true;
|
|
1805
|
+
return false;
|
|
1806
|
+
}
|
|
1807
|
+
function isEntity(xmlData, i) {
|
|
1808
|
+
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y")
|
|
1809
|
+
return true;
|
|
1810
|
+
return false;
|
|
1811
|
+
}
|
|
1812
|
+
function isElement(xmlData, i) {
|
|
1813
|
+
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T")
|
|
1814
|
+
return true;
|
|
1815
|
+
return false;
|
|
1816
|
+
}
|
|
1817
|
+
function isAttlist(xmlData, i) {
|
|
1818
|
+
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T")
|
|
1819
|
+
return true;
|
|
1820
|
+
return false;
|
|
1821
|
+
}
|
|
1822
|
+
function isNotation(xmlData, i) {
|
|
1823
|
+
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N")
|
|
1824
|
+
return true;
|
|
1825
|
+
return false;
|
|
1826
|
+
}
|
|
1827
|
+
function validateEntityName(name) {
|
|
1828
|
+
if (util$1.isName(name))
|
|
1829
|
+
return name;
|
|
1830
|
+
else
|
|
1831
|
+
throw new Error(`Invalid entity name ${name}`);
|
|
1832
|
+
}
|
|
1833
|
+
var DocTypeReader = readDocType$1;
|
|
1834
|
+
const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
|
|
1835
|
+
const numRegex = /^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;
|
|
1836
|
+
if (!Number.parseInt && window.parseInt) {
|
|
1837
|
+
Number.parseInt = window.parseInt;
|
|
1838
|
+
}
|
|
1839
|
+
if (!Number.parseFloat && window.parseFloat) {
|
|
1840
|
+
Number.parseFloat = window.parseFloat;
|
|
1841
|
+
}
|
|
1842
|
+
const consider = {
|
|
1843
|
+
hex: true,
|
|
1844
|
+
leadingZeros: true,
|
|
1402
1845
|
decimalPoint: ".",
|
|
1403
|
-
eNotation:
|
|
1846
|
+
eNotation: true
|
|
1404
1847
|
//skipLike: /regex/
|
|
1405
1848
|
};
|
|
1406
|
-
function
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
if (!
|
|
1423
|
-
return
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1849
|
+
function toNumber$1(str, options = {}) {
|
|
1850
|
+
options = Object.assign({}, consider, options);
|
|
1851
|
+
if (!str || typeof str !== "string")
|
|
1852
|
+
return str;
|
|
1853
|
+
let trimmedStr = str.trim();
|
|
1854
|
+
if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr))
|
|
1855
|
+
return str;
|
|
1856
|
+
else if (options.hex && hexRegex.test(trimmedStr)) {
|
|
1857
|
+
return Number.parseInt(trimmedStr, 16);
|
|
1858
|
+
} else {
|
|
1859
|
+
const match = numRegex.exec(trimmedStr);
|
|
1860
|
+
if (match) {
|
|
1861
|
+
const sign = match[1];
|
|
1862
|
+
const leadingZeros = match[2];
|
|
1863
|
+
let numTrimmedByZeros = trimZeros(match[3]);
|
|
1864
|
+
const eNotation = match[4] || match[6];
|
|
1865
|
+
if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".")
|
|
1866
|
+
return str;
|
|
1867
|
+
else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".")
|
|
1868
|
+
return str;
|
|
1869
|
+
else {
|
|
1870
|
+
const num = Number(trimmedStr);
|
|
1871
|
+
const numStr = "" + num;
|
|
1872
|
+
if (numStr.search(/[eE]/) !== -1) {
|
|
1873
|
+
if (options.eNotation)
|
|
1874
|
+
return num;
|
|
1875
|
+
else
|
|
1876
|
+
return str;
|
|
1877
|
+
} else if (eNotation) {
|
|
1878
|
+
if (options.eNotation)
|
|
1879
|
+
return num;
|
|
1880
|
+
else
|
|
1881
|
+
return str;
|
|
1882
|
+
} else if (trimmedStr.indexOf(".") !== -1) {
|
|
1883
|
+
if (numStr === "0" && numTrimmedByZeros === "")
|
|
1884
|
+
return num;
|
|
1885
|
+
else if (numStr === numTrimmedByZeros)
|
|
1886
|
+
return num;
|
|
1887
|
+
else if (sign && numStr === "-" + numTrimmedByZeros)
|
|
1888
|
+
return num;
|
|
1889
|
+
else
|
|
1890
|
+
return str;
|
|
1891
|
+
}
|
|
1892
|
+
if (leadingZeros) {
|
|
1893
|
+
if (numTrimmedByZeros === numStr)
|
|
1894
|
+
return num;
|
|
1895
|
+
else if (sign + numTrimmedByZeros === numStr)
|
|
1896
|
+
return num;
|
|
1897
|
+
else
|
|
1898
|
+
return str;
|
|
1899
|
+
}
|
|
1900
|
+
if (trimmedStr === numStr)
|
|
1901
|
+
return num;
|
|
1902
|
+
else if (trimmedStr === sign + numStr)
|
|
1903
|
+
return num;
|
|
1904
|
+
return str;
|
|
1427
1905
|
}
|
|
1428
|
-
} else
|
|
1429
|
-
return
|
|
1430
|
-
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1906
|
+
} else {
|
|
1907
|
+
return str;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
function trimZeros(numStr) {
|
|
1912
|
+
if (numStr && numStr.indexOf(".") !== -1) {
|
|
1913
|
+
numStr = numStr.replace(/0+$/, "");
|
|
1914
|
+
if (numStr === ".")
|
|
1915
|
+
numStr = "0";
|
|
1916
|
+
else if (numStr[0] === ".")
|
|
1917
|
+
numStr = "0" + numStr;
|
|
1918
|
+
else if (numStr[numStr.length - 1] === ".")
|
|
1919
|
+
numStr = numStr.substr(0, numStr.length - 1);
|
|
1920
|
+
return numStr;
|
|
1921
|
+
}
|
|
1922
|
+
return numStr;
|
|
1923
|
+
}
|
|
1924
|
+
var strnum = toNumber$1;
|
|
1925
|
+
const util = util$3;
|
|
1926
|
+
const xmlNode = xmlNode$1;
|
|
1927
|
+
const readDocType = DocTypeReader;
|
|
1928
|
+
const toNumber = strnum;
|
|
1929
|
+
let OrderedObjParser$1 = class OrderedObjParser {
|
|
1930
|
+
constructor(options) {
|
|
1931
|
+
this.options = options;
|
|
1932
|
+
this.currentNode = null;
|
|
1933
|
+
this.tagsNodeStack = [];
|
|
1934
|
+
this.docTypeEntities = {};
|
|
1935
|
+
this.lastEntities = {
|
|
1936
|
+
"apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
1937
|
+
"gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
|
|
1938
|
+
"lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
|
|
1939
|
+
"quot": { regex: /&(quot|#34|#x22);/g, val: '"' }
|
|
1940
|
+
};
|
|
1941
|
+
this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
|
|
1942
|
+
this.htmlEntities = {
|
|
1943
|
+
"space": { regex: /&(nbsp|#160);/g, val: " " },
|
|
1446
1944
|
// "lt" : { regex: /&(lt|#60);/g, val: "<" },
|
|
1447
1945
|
// "gt" : { regex: /&(gt|#62);/g, val: ">" },
|
|
1448
1946
|
// "amp" : { regex: /&(amp|#38);/g, val: "&" },
|
|
1449
1947
|
// "quot" : { regex: /&(quot|#34);/g, val: "\"" },
|
|
1450
1948
|
// "apos" : { regex: /&(apos|#39);/g, val: "'" },
|
|
1451
|
-
cent: { regex: /&(cent|#162);/g, val: "¢" },
|
|
1452
|
-
pound: { regex: /&(pound|#163);/g, val: "£" },
|
|
1453
|
-
yen: { regex: /&(yen|#165);/g, val: "¥" },
|
|
1454
|
-
euro: { regex: /&(euro|#8364);/g, val: "€" },
|
|
1455
|
-
copyright: { regex: /&(copy|#169);/g, val: "©" },
|
|
1456
|
-
reg: { regex: /&(reg|#174);/g, val: "®" },
|
|
1457
|
-
inr: { regex: /&(inr|#8377);/g, val: "₹" },
|
|
1458
|
-
num_dec: { regex: /&#([0-9]{1,7});/g, val: (
|
|
1459
|
-
num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (
|
|
1460
|
-
}
|
|
1949
|
+
"cent": { regex: /&(cent|#162);/g, val: "¢" },
|
|
1950
|
+
"pound": { regex: /&(pound|#163);/g, val: "£" },
|
|
1951
|
+
"yen": { regex: /&(yen|#165);/g, val: "¥" },
|
|
1952
|
+
"euro": { regex: /&(euro|#8364);/g, val: "€" },
|
|
1953
|
+
"copyright": { regex: /&(copy|#169);/g, val: "©" },
|
|
1954
|
+
"reg": { regex: /&(reg|#174);/g, val: "®" },
|
|
1955
|
+
"inr": { regex: /&(inr|#8377);/g, val: "₹" },
|
|
1956
|
+
"num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },
|
|
1957
|
+
"num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 16)) }
|
|
1958
|
+
};
|
|
1959
|
+
this.addExternalEntities = addExternalEntities;
|
|
1960
|
+
this.parseXml = parseXml;
|
|
1961
|
+
this.parseTextData = parseTextData;
|
|
1962
|
+
this.resolveNameSpace = resolveNameSpace;
|
|
1963
|
+
this.buildAttributesMap = buildAttributesMap;
|
|
1964
|
+
this.isItStopNode = isItStopNode;
|
|
1965
|
+
this.replaceEntitiesValue = replaceEntitiesValue$1;
|
|
1966
|
+
this.readStopNodeData = readStopNodeData;
|
|
1967
|
+
this.saveTextToParentTag = saveTextToParentTag;
|
|
1968
|
+
this.addChild = addChild;
|
|
1461
1969
|
}
|
|
1462
1970
|
};
|
|
1463
|
-
function
|
|
1464
|
-
const
|
|
1465
|
-
for (let
|
|
1466
|
-
const
|
|
1467
|
-
this.lastEntities[
|
|
1468
|
-
regex: new RegExp("&" +
|
|
1469
|
-
val:
|
|
1971
|
+
function addExternalEntities(externalEntities) {
|
|
1972
|
+
const entKeys = Object.keys(externalEntities);
|
|
1973
|
+
for (let i = 0; i < entKeys.length; i++) {
|
|
1974
|
+
const ent = entKeys[i];
|
|
1975
|
+
this.lastEntities[ent] = {
|
|
1976
|
+
regex: new RegExp("&" + ent + ";", "g"),
|
|
1977
|
+
val: externalEntities[ent]
|
|
1470
1978
|
};
|
|
1471
1979
|
}
|
|
1472
1980
|
}
|
|
1473
|
-
function
|
|
1474
|
-
if (
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1981
|
+
function parseTextData(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
|
|
1982
|
+
if (val2 !== void 0) {
|
|
1983
|
+
if (this.options.trimValues && !dontTrim) {
|
|
1984
|
+
val2 = val2.trim();
|
|
1985
|
+
}
|
|
1986
|
+
if (val2.length > 0) {
|
|
1987
|
+
if (!escapeEntities)
|
|
1988
|
+
val2 = this.replaceEntitiesValue(val2);
|
|
1989
|
+
const newval = this.options.tagValueProcessor(tagName, val2, jPath, hasAttributes, isLeafNode);
|
|
1990
|
+
if (newval === null || newval === void 0) {
|
|
1991
|
+
return val2;
|
|
1992
|
+
} else if (typeof newval !== typeof val2 || newval !== val2) {
|
|
1993
|
+
return newval;
|
|
1994
|
+
} else if (this.options.trimValues) {
|
|
1995
|
+
return parseValue(val2, this.options.parseTagValue, this.options.numberParseOptions);
|
|
1996
|
+
} else {
|
|
1997
|
+
const trimmedVal = val2.trim();
|
|
1998
|
+
if (trimmedVal === val2) {
|
|
1999
|
+
return parseValue(val2, this.options.parseTagValue, this.options.numberParseOptions);
|
|
2000
|
+
} else {
|
|
2001
|
+
return val2;
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
1478
2005
|
}
|
|
1479
2006
|
}
|
|
1480
|
-
function
|
|
2007
|
+
function resolveNameSpace(tagname) {
|
|
1481
2008
|
if (this.options.removeNSPrefix) {
|
|
1482
|
-
const
|
|
1483
|
-
|
|
2009
|
+
const tags = tagname.split(":");
|
|
2010
|
+
const prefix = tagname.charAt(0) === "/" ? "/" : "";
|
|
2011
|
+
if (tags[0] === "xmlns") {
|
|
1484
2012
|
return "";
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
);
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
2013
|
+
}
|
|
2014
|
+
if (tags.length === 2) {
|
|
2015
|
+
tagname = prefix + tags[1];
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
return tagname;
|
|
2019
|
+
}
|
|
2020
|
+
const attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
2021
|
+
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
2022
|
+
if (!this.options.ignoreAttributes && typeof attrStr === "string") {
|
|
2023
|
+
const matches = util.getAllMatches(attrStr, attrsRegx);
|
|
2024
|
+
const len = matches.length;
|
|
2025
|
+
const attrs = {};
|
|
2026
|
+
for (let i = 0; i < len; i++) {
|
|
2027
|
+
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
2028
|
+
let oldVal = matches[i][4];
|
|
2029
|
+
let aName = this.options.attributeNamePrefix + attrName;
|
|
2030
|
+
if (attrName.length) {
|
|
2031
|
+
if (this.options.transformAttributeName) {
|
|
2032
|
+
aName = this.options.transformAttributeName(aName);
|
|
2033
|
+
}
|
|
2034
|
+
if (aName === "__proto__")
|
|
2035
|
+
aName = "#__proto__";
|
|
2036
|
+
if (oldVal !== void 0) {
|
|
2037
|
+
if (this.options.trimValues) {
|
|
2038
|
+
oldVal = oldVal.trim();
|
|
2039
|
+
}
|
|
2040
|
+
oldVal = this.replaceEntitiesValue(oldVal);
|
|
2041
|
+
const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
|
|
2042
|
+
if (newVal === null || newVal === void 0) {
|
|
2043
|
+
attrs[aName] = oldVal;
|
|
2044
|
+
} else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
|
|
2045
|
+
attrs[aName] = newVal;
|
|
2046
|
+
} else {
|
|
2047
|
+
attrs[aName] = parseValue(
|
|
2048
|
+
oldVal,
|
|
2049
|
+
this.options.parseAttributeValue,
|
|
2050
|
+
this.options.numberParseOptions
|
|
2051
|
+
);
|
|
2052
|
+
}
|
|
2053
|
+
} else if (this.options.allowBooleanAttributes) {
|
|
2054
|
+
attrs[aName] = true;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
if (!Object.keys(attrs).length) {
|
|
1509
2059
|
return;
|
|
2060
|
+
}
|
|
1510
2061
|
if (this.options.attributesGroupName) {
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
const
|
|
1521
|
-
let
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
2062
|
+
const attrCollection = {};
|
|
2063
|
+
attrCollection[this.options.attributesGroupName] = attrs;
|
|
2064
|
+
return attrCollection;
|
|
2065
|
+
}
|
|
2066
|
+
return attrs;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
const parseXml = function(xmlData) {
|
|
2070
|
+
xmlData = xmlData.replace(/\r\n?/g, "\n");
|
|
2071
|
+
const xmlObj = new xmlNode("!xml");
|
|
2072
|
+
let currentNode = xmlObj;
|
|
2073
|
+
let textData = "";
|
|
2074
|
+
let jPath = "";
|
|
2075
|
+
for (let i = 0; i < xmlData.length; i++) {
|
|
2076
|
+
const ch = xmlData[i];
|
|
2077
|
+
if (ch === "<") {
|
|
2078
|
+
if (xmlData[i + 1] === "/") {
|
|
2079
|
+
const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
|
|
2080
|
+
let tagName = xmlData.substring(i + 2, closeIndex).trim();
|
|
1527
2081
|
if (this.options.removeNSPrefix) {
|
|
1528
|
-
const
|
|
1529
|
-
|
|
2082
|
+
const colonIndex = tagName.indexOf(":");
|
|
2083
|
+
if (colonIndex !== -1) {
|
|
2084
|
+
tagName = tagName.substr(colonIndex + 1);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
if (this.options.transformTagName) {
|
|
2088
|
+
tagName = this.options.transformTagName(tagName);
|
|
2089
|
+
}
|
|
2090
|
+
if (currentNode) {
|
|
2091
|
+
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
1530
2092
|
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
let
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
2093
|
+
const lastTagName = jPath.substring(jPath.lastIndexOf(".") + 1);
|
|
2094
|
+
if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
|
|
2095
|
+
throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
|
|
2096
|
+
}
|
|
2097
|
+
let propIndex = 0;
|
|
2098
|
+
if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
|
|
2099
|
+
propIndex = jPath.lastIndexOf(".", jPath.lastIndexOf(".") - 1);
|
|
2100
|
+
this.tagsNodeStack.pop();
|
|
2101
|
+
} else {
|
|
2102
|
+
propIndex = jPath.lastIndexOf(".");
|
|
2103
|
+
}
|
|
2104
|
+
jPath = jPath.substring(0, propIndex);
|
|
2105
|
+
currentNode = this.tagsNodeStack.pop();
|
|
2106
|
+
textData = "";
|
|
2107
|
+
i = closeIndex;
|
|
2108
|
+
} else if (xmlData[i + 1] === "?") {
|
|
2109
|
+
let tagData = readTagExp(xmlData, i, false, "?>");
|
|
2110
|
+
if (!tagData)
|
|
1540
2111
|
throw new Error("Pi Tag is not closed.");
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
2112
|
+
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
2113
|
+
if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags)
|
|
2114
|
+
;
|
|
2115
|
+
else {
|
|
2116
|
+
const childNode = new xmlNode(tagData.tagName);
|
|
2117
|
+
childNode.add(this.options.textNodeName, "");
|
|
2118
|
+
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
|
|
2119
|
+
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
|
|
2120
|
+
}
|
|
2121
|
+
this.addChild(currentNode, childNode, jPath);
|
|
1544
2122
|
}
|
|
1545
|
-
i =
|
|
1546
|
-
} else if (
|
|
1547
|
-
const
|
|
2123
|
+
i = tagData.closeIndex + 1;
|
|
2124
|
+
} else if (xmlData.substr(i + 1, 3) === "!--") {
|
|
2125
|
+
const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
|
|
1548
2126
|
if (this.options.commentPropName) {
|
|
1549
|
-
const
|
|
1550
|
-
|
|
2127
|
+
const comment = xmlData.substring(i + 4, endIndex - 2);
|
|
2128
|
+
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
2129
|
+
currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
|
|
2130
|
+
}
|
|
2131
|
+
i = endIndex;
|
|
2132
|
+
} else if (xmlData.substr(i + 1, 2) === "!D") {
|
|
2133
|
+
const result = readDocType(xmlData, i);
|
|
2134
|
+
this.docTypeEntities = result.entities;
|
|
2135
|
+
i = result.i;
|
|
2136
|
+
} else if (xmlData.substr(i + 1, 2) === "![") {
|
|
2137
|
+
const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
|
|
2138
|
+
const tagExp = xmlData.substring(i + 9, closeIndex);
|
|
2139
|
+
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
2140
|
+
let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
|
|
2141
|
+
if (val2 == void 0)
|
|
2142
|
+
val2 = "";
|
|
2143
|
+
if (this.options.cdataPropName) {
|
|
2144
|
+
currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
|
|
2145
|
+
} else {
|
|
2146
|
+
currentNode.add(this.options.textNodeName, val2);
|
|
1551
2147
|
}
|
|
1552
|
-
i =
|
|
1553
|
-
} else if (e.substr(i + 1, 2) === "!D") {
|
|
1554
|
-
const u = rt(e, i);
|
|
1555
|
-
this.docTypeEntities = u.entities, i = u.i;
|
|
1556
|
-
} else if (e.substr(i + 1, 2) === "![") {
|
|
1557
|
-
const u = y(e, "]]>", i, "CDATA is not closed.") - 2, o = e.substring(i + 9, u);
|
|
1558
|
-
s = this.saveTextToParentTag(s, r, n);
|
|
1559
|
-
let a = this.parseTextData(o, r.tagname, n, !0, !1, !0, !0);
|
|
1560
|
-
a == null && (a = ""), this.options.cdataPropName ? r.add(this.options.cdataPropName, [{ [this.options.textNodeName]: o }]) : r.add(this.options.textNodeName, a), i = u + 2;
|
|
2148
|
+
i = closeIndex + 2;
|
|
1561
2149
|
} else {
|
|
1562
|
-
let
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
const E = this.readStopNodeData(e, a, c + 1);
|
|
1575
|
-
if (!E)
|
|
1576
|
-
throw new Error(`Unexpected end of ${a}`);
|
|
1577
|
-
i = E.i, h = E.tagContent;
|
|
2150
|
+
let result = readTagExp(xmlData, i, this.options.removeNSPrefix);
|
|
2151
|
+
let tagName = result.tagName;
|
|
2152
|
+
const rawTagName = result.rawTagName;
|
|
2153
|
+
let tagExp = result.tagExp;
|
|
2154
|
+
let attrExpPresent = result.attrExpPresent;
|
|
2155
|
+
let closeIndex = result.closeIndex;
|
|
2156
|
+
if (this.options.transformTagName) {
|
|
2157
|
+
tagName = this.options.transformTagName(tagName);
|
|
2158
|
+
}
|
|
2159
|
+
if (currentNode && textData) {
|
|
2160
|
+
if (currentNode.tagname !== "!xml") {
|
|
2161
|
+
textData = this.saveTextToParentTag(textData, currentNode, jPath, false);
|
|
1578
2162
|
}
|
|
1579
|
-
|
|
1580
|
-
|
|
2163
|
+
}
|
|
2164
|
+
const lastTag = currentNode;
|
|
2165
|
+
if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
|
|
2166
|
+
currentNode = this.tagsNodeStack.pop();
|
|
2167
|
+
jPath = jPath.substring(0, jPath.lastIndexOf("."));
|
|
2168
|
+
}
|
|
2169
|
+
if (tagName !== xmlObj.tagname) {
|
|
2170
|
+
jPath += jPath ? "." + tagName : tagName;
|
|
2171
|
+
}
|
|
2172
|
+
if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
|
|
2173
|
+
let tagContent = "";
|
|
2174
|
+
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
2175
|
+
i = result.closeIndex;
|
|
2176
|
+
} else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
|
|
2177
|
+
i = result.closeIndex;
|
|
2178
|
+
} else {
|
|
2179
|
+
const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
|
|
2180
|
+
if (!result2)
|
|
2181
|
+
throw new Error(`Unexpected end of ${rawTagName}`);
|
|
2182
|
+
i = result2.i;
|
|
2183
|
+
tagContent = result2.tagContent;
|
|
2184
|
+
}
|
|
2185
|
+
const childNode = new xmlNode(tagName);
|
|
2186
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
2187
|
+
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
2188
|
+
}
|
|
2189
|
+
if (tagContent) {
|
|
2190
|
+
tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
|
|
2191
|
+
}
|
|
2192
|
+
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
2193
|
+
childNode.add(this.options.textNodeName, tagContent);
|
|
2194
|
+
this.addChild(currentNode, childNode, jPath);
|
|
1581
2195
|
} else {
|
|
1582
|
-
if (
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
2196
|
+
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
2197
|
+
if (tagName[tagName.length - 1] === "/") {
|
|
2198
|
+
tagName = tagName.substr(0, tagName.length - 1);
|
|
2199
|
+
jPath = jPath.substr(0, jPath.length - 1);
|
|
2200
|
+
tagExp = tagName;
|
|
2201
|
+
} else {
|
|
2202
|
+
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
2203
|
+
}
|
|
2204
|
+
if (this.options.transformTagName) {
|
|
2205
|
+
tagName = this.options.transformTagName(tagName);
|
|
2206
|
+
}
|
|
2207
|
+
const childNode = new xmlNode(tagName);
|
|
2208
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
2209
|
+
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
2210
|
+
}
|
|
2211
|
+
this.addChild(currentNode, childNode, jPath);
|
|
2212
|
+
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
1586
2213
|
} else {
|
|
1587
|
-
const
|
|
1588
|
-
this.tagsNodeStack.push(
|
|
2214
|
+
const childNode = new xmlNode(tagName);
|
|
2215
|
+
this.tagsNodeStack.push(currentNode);
|
|
2216
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
2217
|
+
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
2218
|
+
}
|
|
2219
|
+
this.addChild(currentNode, childNode, jPath);
|
|
2220
|
+
currentNode = childNode;
|
|
1589
2221
|
}
|
|
1590
|
-
|
|
2222
|
+
textData = "";
|
|
2223
|
+
i = closeIndex;
|
|
1591
2224
|
}
|
|
1592
2225
|
}
|
|
1593
|
-
else
|
|
1594
|
-
|
|
1595
|
-
|
|
2226
|
+
} else {
|
|
2227
|
+
textData += xmlData[i];
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
return xmlObj.child;
|
|
1596
2231
|
};
|
|
1597
|
-
function
|
|
1598
|
-
const
|
|
1599
|
-
|
|
2232
|
+
function addChild(currentNode, childNode, jPath) {
|
|
2233
|
+
const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
|
|
2234
|
+
if (result === false)
|
|
2235
|
+
;
|
|
2236
|
+
else if (typeof result === "string") {
|
|
2237
|
+
childNode.tagname = result;
|
|
2238
|
+
currentNode.addChild(childNode);
|
|
2239
|
+
} else {
|
|
2240
|
+
currentNode.addChild(childNode);
|
|
2241
|
+
}
|
|
1600
2242
|
}
|
|
1601
|
-
const
|
|
2243
|
+
const replaceEntitiesValue$1 = function(val2) {
|
|
1602
2244
|
if (this.options.processEntities) {
|
|
1603
|
-
for (let
|
|
1604
|
-
const
|
|
1605
|
-
|
|
1606
|
-
}
|
|
1607
|
-
for (let
|
|
1608
|
-
const
|
|
1609
|
-
|
|
1610
|
-
}
|
|
1611
|
-
if (this.options.htmlEntities)
|
|
1612
|
-
for (let
|
|
1613
|
-
const
|
|
1614
|
-
|
|
2245
|
+
for (let entityName2 in this.docTypeEntities) {
|
|
2246
|
+
const entity = this.docTypeEntities[entityName2];
|
|
2247
|
+
val2 = val2.replace(entity.regx, entity.val);
|
|
2248
|
+
}
|
|
2249
|
+
for (let entityName2 in this.lastEntities) {
|
|
2250
|
+
const entity = this.lastEntities[entityName2];
|
|
2251
|
+
val2 = val2.replace(entity.regex, entity.val);
|
|
2252
|
+
}
|
|
2253
|
+
if (this.options.htmlEntities) {
|
|
2254
|
+
for (let entityName2 in this.htmlEntities) {
|
|
2255
|
+
const entity = this.htmlEntities[entityName2];
|
|
2256
|
+
val2 = val2.replace(entity.regex, entity.val);
|
|
1615
2257
|
}
|
|
1616
|
-
|
|
2258
|
+
}
|
|
2259
|
+
val2 = val2.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
1617
2260
|
}
|
|
1618
|
-
return
|
|
2261
|
+
return val2;
|
|
1619
2262
|
};
|
|
1620
|
-
function
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
2263
|
+
function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
|
|
2264
|
+
if (textData) {
|
|
2265
|
+
if (isLeafNode === void 0)
|
|
2266
|
+
isLeafNode = Object.keys(currentNode.child).length === 0;
|
|
2267
|
+
textData = this.parseTextData(
|
|
2268
|
+
textData,
|
|
2269
|
+
currentNode.tagname,
|
|
2270
|
+
jPath,
|
|
2271
|
+
false,
|
|
2272
|
+
currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false,
|
|
2273
|
+
isLeafNode
|
|
2274
|
+
);
|
|
2275
|
+
if (textData !== void 0 && textData !== "")
|
|
2276
|
+
currentNode.add(this.options.textNodeName, textData);
|
|
2277
|
+
textData = "";
|
|
2278
|
+
}
|
|
2279
|
+
return textData;
|
|
2280
|
+
}
|
|
2281
|
+
function isItStopNode(stopNodes, jPath, currentTagName) {
|
|
2282
|
+
const allNodesExp = "*." + currentTagName;
|
|
2283
|
+
for (const stopNodePath in stopNodes) {
|
|
2284
|
+
const stopNodeExp = stopNodes[stopNodePath];
|
|
2285
|
+
if (allNodesExp === stopNodeExp || jPath === stopNodeExp)
|
|
2286
|
+
return true;
|
|
2287
|
+
}
|
|
2288
|
+
return false;
|
|
2289
|
+
}
|
|
2290
|
+
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
|
|
2291
|
+
let attrBoundary;
|
|
2292
|
+
let tagExp = "";
|
|
2293
|
+
for (let index = i; index < xmlData.length; index++) {
|
|
2294
|
+
let ch = xmlData[index];
|
|
2295
|
+
if (attrBoundary) {
|
|
2296
|
+
if (ch === attrBoundary)
|
|
2297
|
+
attrBoundary = "";
|
|
2298
|
+
} else if (ch === '"' || ch === "'") {
|
|
2299
|
+
attrBoundary = ch;
|
|
2300
|
+
} else if (ch === closingChar[0]) {
|
|
2301
|
+
if (closingChar[1]) {
|
|
2302
|
+
if (xmlData[index + 1] === closingChar[1]) {
|
|
1650
2303
|
return {
|
|
1651
|
-
data:
|
|
1652
|
-
index
|
|
2304
|
+
data: tagExp,
|
|
2305
|
+
index
|
|
1653
2306
|
};
|
|
1654
|
-
|
|
2307
|
+
}
|
|
2308
|
+
} else {
|
|
1655
2309
|
return {
|
|
1656
|
-
data:
|
|
1657
|
-
index
|
|
2310
|
+
data: tagExp,
|
|
2311
|
+
index
|
|
1658
2312
|
};
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
2313
|
+
}
|
|
2314
|
+
} else if (ch === " ") {
|
|
2315
|
+
ch = " ";
|
|
2316
|
+
}
|
|
2317
|
+
tagExp += ch;
|
|
1662
2318
|
}
|
|
1663
2319
|
}
|
|
1664
|
-
function
|
|
1665
|
-
const
|
|
1666
|
-
if (
|
|
1667
|
-
throw new Error(
|
|
1668
|
-
|
|
2320
|
+
function findClosingIndex(xmlData, str, i, errMsg) {
|
|
2321
|
+
const closingIndex = xmlData.indexOf(str, i);
|
|
2322
|
+
if (closingIndex === -1) {
|
|
2323
|
+
throw new Error(errMsg);
|
|
2324
|
+
} else {
|
|
2325
|
+
return closingIndex + str.length - 1;
|
|
2326
|
+
}
|
|
1669
2327
|
}
|
|
1670
|
-
function
|
|
1671
|
-
const
|
|
1672
|
-
if (!
|
|
2328
|
+
function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
|
|
2329
|
+
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
2330
|
+
if (!result)
|
|
1673
2331
|
return;
|
|
1674
|
-
let
|
|
1675
|
-
const
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
if (
|
|
1680
|
-
|
|
1681
|
-
|
|
2332
|
+
let tagExp = result.data;
|
|
2333
|
+
const closeIndex = result.index;
|
|
2334
|
+
const separatorIndex = tagExp.search(/\s/);
|
|
2335
|
+
let tagName = tagExp;
|
|
2336
|
+
let attrExpPresent = true;
|
|
2337
|
+
if (separatorIndex !== -1) {
|
|
2338
|
+
tagName = tagExp.substring(0, separatorIndex);
|
|
2339
|
+
tagExp = tagExp.substring(separatorIndex + 1).trimStart();
|
|
2340
|
+
}
|
|
2341
|
+
const rawTagName = tagName;
|
|
2342
|
+
if (removeNSPrefix) {
|
|
2343
|
+
const colonIndex = tagName.indexOf(":");
|
|
2344
|
+
if (colonIndex !== -1) {
|
|
2345
|
+
tagName = tagName.substr(colonIndex + 1);
|
|
2346
|
+
attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
|
|
2347
|
+
}
|
|
1682
2348
|
}
|
|
1683
2349
|
return {
|
|
1684
|
-
tagName
|
|
1685
|
-
tagExp
|
|
1686
|
-
closeIndex
|
|
1687
|
-
attrExpPresent
|
|
1688
|
-
rawTagName
|
|
2350
|
+
tagName,
|
|
2351
|
+
tagExp,
|
|
2352
|
+
closeIndex,
|
|
2353
|
+
attrExpPresent,
|
|
2354
|
+
rawTagName
|
|
1689
2355
|
};
|
|
1690
2356
|
}
|
|
1691
|
-
function
|
|
1692
|
-
const
|
|
1693
|
-
let
|
|
1694
|
-
for (;
|
|
1695
|
-
if (
|
|
1696
|
-
if (
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
2357
|
+
function readStopNodeData(xmlData, tagName, i) {
|
|
2358
|
+
const startIndex = i;
|
|
2359
|
+
let openTagCount = 1;
|
|
2360
|
+
for (; i < xmlData.length; i++) {
|
|
2361
|
+
if (xmlData[i] === "<") {
|
|
2362
|
+
if (xmlData[i + 1] === "/") {
|
|
2363
|
+
const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`);
|
|
2364
|
+
let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
|
|
2365
|
+
if (closeTagName === tagName) {
|
|
2366
|
+
openTagCount--;
|
|
2367
|
+
if (openTagCount === 0) {
|
|
2368
|
+
return {
|
|
2369
|
+
tagContent: xmlData.substring(startIndex, i),
|
|
2370
|
+
i: closeIndex
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
i = closeIndex;
|
|
2375
|
+
} else if (xmlData[i + 1] === "?") {
|
|
2376
|
+
const closeIndex = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
|
|
2377
|
+
i = closeIndex;
|
|
2378
|
+
} else if (xmlData.substr(i + 1, 3) === "!--") {
|
|
2379
|
+
const closeIndex = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
|
|
2380
|
+
i = closeIndex;
|
|
2381
|
+
} else if (xmlData.substr(i + 1, 2) === "![") {
|
|
2382
|
+
const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
|
|
2383
|
+
i = closeIndex;
|
|
2384
|
+
} else {
|
|
2385
|
+
const tagData = readTagExp(xmlData, i, ">");
|
|
2386
|
+
if (tagData) {
|
|
2387
|
+
const openTagName = tagData && tagData.tagName;
|
|
2388
|
+
if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
|
|
2389
|
+
openTagCount++;
|
|
2390
|
+
}
|
|
2391
|
+
i = tagData.closeIndex;
|
|
2392
|
+
}
|
|
1713
2393
|
}
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
1714
2396
|
}
|
|
1715
|
-
function
|
|
1716
|
-
if (
|
|
1717
|
-
const
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
2397
|
+
function parseValue(val2, shouldParse, options) {
|
|
2398
|
+
if (shouldParse && typeof val2 === "string") {
|
|
2399
|
+
const newval = val2.trim();
|
|
2400
|
+
if (newval === "true")
|
|
2401
|
+
return true;
|
|
2402
|
+
else if (newval === "false")
|
|
2403
|
+
return false;
|
|
2404
|
+
else
|
|
2405
|
+
return toNumber(val2, options);
|
|
2406
|
+
} else {
|
|
2407
|
+
if (util.isExist(val2)) {
|
|
2408
|
+
return val2;
|
|
2409
|
+
} else {
|
|
2410
|
+
return "";
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
var OrderedObjParser_1 = OrderedObjParser$1;
|
|
2415
|
+
var node2json = {};
|
|
2416
|
+
function prettify$1(node, options) {
|
|
2417
|
+
return compress(node, options);
|
|
2418
|
+
}
|
|
2419
|
+
function compress(arr, options, jPath) {
|
|
2420
|
+
let text;
|
|
2421
|
+
const compressedObj = {};
|
|
2422
|
+
for (let i = 0; i < arr.length; i++) {
|
|
2423
|
+
const tagObj = arr[i];
|
|
2424
|
+
const property = propName$1(tagObj);
|
|
2425
|
+
let newJpath = "";
|
|
2426
|
+
if (jPath === void 0)
|
|
2427
|
+
newJpath = property;
|
|
2428
|
+
else
|
|
2429
|
+
newJpath = jPath + "." + property;
|
|
2430
|
+
if (property === options.textNodeName) {
|
|
2431
|
+
if (text === void 0)
|
|
2432
|
+
text = tagObj[property];
|
|
2433
|
+
else
|
|
2434
|
+
text += "" + tagObj[property];
|
|
2435
|
+
} else if (property === void 0) {
|
|
2436
|
+
continue;
|
|
2437
|
+
} else if (tagObj[property]) {
|
|
2438
|
+
let val2 = compress(tagObj[property], options, newJpath);
|
|
2439
|
+
const isLeaf = isLeafTag(val2, options);
|
|
2440
|
+
if (tagObj[":@"]) {
|
|
2441
|
+
assignAttributes(val2, tagObj[":@"], newJpath, options);
|
|
2442
|
+
} else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
|
|
2443
|
+
val2 = val2[options.textNodeName];
|
|
2444
|
+
} else if (Object.keys(val2).length === 0) {
|
|
2445
|
+
if (options.alwaysCreateTextNode)
|
|
2446
|
+
val2[options.textNodeName] = "";
|
|
2447
|
+
else
|
|
2448
|
+
val2 = "";
|
|
2449
|
+
}
|
|
2450
|
+
if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
|
|
2451
|
+
if (!Array.isArray(compressedObj[property])) {
|
|
2452
|
+
compressedObj[property] = [compressedObj[property]];
|
|
2453
|
+
}
|
|
2454
|
+
compressedObj[property].push(val2);
|
|
2455
|
+
} else {
|
|
2456
|
+
if (options.isArray(property, newJpath, isLeaf)) {
|
|
2457
|
+
compressedObj[property] = [val2];
|
|
2458
|
+
} else {
|
|
2459
|
+
compressedObj[property] = val2;
|
|
2460
|
+
}
|
|
1741
2461
|
}
|
|
1742
2462
|
}
|
|
1743
2463
|
}
|
|
1744
|
-
|
|
2464
|
+
if (typeof text === "string") {
|
|
2465
|
+
if (text.length > 0)
|
|
2466
|
+
compressedObj[options.textNodeName] = text;
|
|
2467
|
+
} else if (text !== void 0)
|
|
2468
|
+
compressedObj[options.textNodeName] = text;
|
|
2469
|
+
return compressedObj;
|
|
1745
2470
|
}
|
|
1746
|
-
function
|
|
1747
|
-
const
|
|
1748
|
-
for (let
|
|
1749
|
-
const
|
|
1750
|
-
if (
|
|
1751
|
-
return
|
|
2471
|
+
function propName$1(obj) {
|
|
2472
|
+
const keys = Object.keys(obj);
|
|
2473
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2474
|
+
const key = keys[i];
|
|
2475
|
+
if (key !== ":@")
|
|
2476
|
+
return key;
|
|
1752
2477
|
}
|
|
1753
2478
|
}
|
|
1754
|
-
function
|
|
1755
|
-
if (
|
|
1756
|
-
const
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
2479
|
+
function assignAttributes(obj, attrMap, jpath, options) {
|
|
2480
|
+
if (attrMap) {
|
|
2481
|
+
const keys = Object.keys(attrMap);
|
|
2482
|
+
const len = keys.length;
|
|
2483
|
+
for (let i = 0; i < len; i++) {
|
|
2484
|
+
const atrrName = keys[i];
|
|
2485
|
+
if (options.isArray(atrrName, jpath + "." + atrrName, true, true)) {
|
|
2486
|
+
obj[atrrName] = [attrMap[atrrName]];
|
|
2487
|
+
} else {
|
|
2488
|
+
obj[atrrName] = attrMap[atrrName];
|
|
2489
|
+
}
|
|
1760
2490
|
}
|
|
1761
2491
|
}
|
|
1762
2492
|
}
|
|
1763
|
-
function
|
|
1764
|
-
const { textNodeName
|
|
1765
|
-
|
|
2493
|
+
function isLeafTag(obj, options) {
|
|
2494
|
+
const { textNodeName } = options;
|
|
2495
|
+
const propCount = Object.keys(obj).length;
|
|
2496
|
+
if (propCount === 0) {
|
|
2497
|
+
return true;
|
|
2498
|
+
}
|
|
2499
|
+
if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
|
|
2500
|
+
return true;
|
|
2501
|
+
}
|
|
2502
|
+
return false;
|
|
1766
2503
|
}
|
|
1767
|
-
|
|
1768
|
-
const { buildOptions
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
2504
|
+
node2json.prettify = prettify$1;
|
|
2505
|
+
const { buildOptions } = OptionsBuilder;
|
|
2506
|
+
const OrderedObjParser2 = OrderedObjParser_1;
|
|
2507
|
+
const { prettify } = node2json;
|
|
2508
|
+
const validator$1 = validator$2;
|
|
2509
|
+
let XMLParser$1 = class XMLParser {
|
|
2510
|
+
constructor(options) {
|
|
2511
|
+
this.externalEntities = {};
|
|
2512
|
+
this.options = buildOptions(options);
|
|
1772
2513
|
}
|
|
1773
2514
|
/**
|
|
1774
2515
|
* Parse XML dats to JS object
|
|
1775
2516
|
* @param {string|Buffer} xmlData
|
|
1776
2517
|
* @param {boolean|Object} validationOption
|
|
1777
2518
|
*/
|
|
1778
|
-
parse(
|
|
1779
|
-
if (typeof
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
if (
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
2519
|
+
parse(xmlData, validationOption) {
|
|
2520
|
+
if (typeof xmlData === "string")
|
|
2521
|
+
;
|
|
2522
|
+
else if (xmlData.toString) {
|
|
2523
|
+
xmlData = xmlData.toString();
|
|
2524
|
+
} else {
|
|
2525
|
+
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
2526
|
+
}
|
|
2527
|
+
if (validationOption) {
|
|
2528
|
+
if (validationOption === true)
|
|
2529
|
+
validationOption = {};
|
|
2530
|
+
const result = validator$1.validate(xmlData, validationOption);
|
|
2531
|
+
if (result !== true) {
|
|
2532
|
+
throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
const orderedObjParser = new OrderedObjParser2(this.options);
|
|
2536
|
+
orderedObjParser.addExternalEntities(this.externalEntities);
|
|
2537
|
+
const orderedResult = orderedObjParser.parseXml(xmlData);
|
|
2538
|
+
if (this.options.preserveOrder || orderedResult === void 0)
|
|
2539
|
+
return orderedResult;
|
|
2540
|
+
else
|
|
2541
|
+
return prettify(orderedResult, this.options);
|
|
1794
2542
|
}
|
|
1795
2543
|
/**
|
|
1796
2544
|
* Add Entity which is not by default supported by this library
|
|
1797
2545
|
* @param {string} key
|
|
1798
2546
|
* @param {string} value
|
|
1799
2547
|
*/
|
|
1800
|
-
addEntity(
|
|
1801
|
-
if (
|
|
2548
|
+
addEntity(key, value) {
|
|
2549
|
+
if (value.indexOf("&") !== -1) {
|
|
1802
2550
|
throw new Error("Entity value can't have '&'");
|
|
1803
|
-
if (
|
|
2551
|
+
} else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
|
|
1804
2552
|
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");
|
|
1805
|
-
if (
|
|
2553
|
+
} else if (value === "&") {
|
|
1806
2554
|
throw new Error("An entity with value '&' is not permitted");
|
|
1807
|
-
|
|
2555
|
+
} else {
|
|
2556
|
+
this.externalEntities[key] = value;
|
|
2557
|
+
}
|
|
1808
2558
|
}
|
|
1809
2559
|
};
|
|
1810
|
-
var
|
|
1811
|
-
const
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
2560
|
+
var XMLParser_1 = XMLParser$1;
|
|
2561
|
+
const EOL = "\n";
|
|
2562
|
+
function toXml(jArray, options) {
|
|
2563
|
+
let indentation = "";
|
|
2564
|
+
if (options.format && options.indentBy.length > 0) {
|
|
2565
|
+
indentation = EOL;
|
|
2566
|
+
}
|
|
2567
|
+
return arrToStr(jArray, options, "", indentation);
|
|
2568
|
+
}
|
|
2569
|
+
function arrToStr(arr, options, jPath, indentation) {
|
|
2570
|
+
let xmlStr = "";
|
|
2571
|
+
let isPreviousElementTag = false;
|
|
2572
|
+
for (let i = 0; i < arr.length; i++) {
|
|
2573
|
+
const tagObj = arr[i];
|
|
2574
|
+
const tagName = propName(tagObj);
|
|
2575
|
+
if (tagName === void 0)
|
|
1822
2576
|
continue;
|
|
1823
|
-
let
|
|
1824
|
-
if (
|
|
1825
|
-
|
|
1826
|
-
|
|
2577
|
+
let newJPath = "";
|
|
2578
|
+
if (jPath.length === 0)
|
|
2579
|
+
newJPath = tagName;
|
|
2580
|
+
else
|
|
2581
|
+
newJPath = `${jPath}.${tagName}`;
|
|
2582
|
+
if (tagName === options.textNodeName) {
|
|
2583
|
+
let tagText = tagObj[tagName];
|
|
2584
|
+
if (!isStopNode(newJPath, options)) {
|
|
2585
|
+
tagText = options.tagValueProcessor(tagName, tagText);
|
|
2586
|
+
tagText = replaceEntitiesValue(tagText, options);
|
|
2587
|
+
}
|
|
2588
|
+
if (isPreviousElementTag) {
|
|
2589
|
+
xmlStr += indentation;
|
|
2590
|
+
}
|
|
2591
|
+
xmlStr += tagText;
|
|
2592
|
+
isPreviousElementTag = false;
|
|
1827
2593
|
continue;
|
|
1828
|
-
} else if (
|
|
1829
|
-
|
|
2594
|
+
} else if (tagName === options.cdataPropName) {
|
|
2595
|
+
if (isPreviousElementTag) {
|
|
2596
|
+
xmlStr += indentation;
|
|
2597
|
+
}
|
|
2598
|
+
xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
|
|
2599
|
+
isPreviousElementTag = false;
|
|
1830
2600
|
continue;
|
|
1831
|
-
} else if (
|
|
1832
|
-
|
|
2601
|
+
} else if (tagName === options.commentPropName) {
|
|
2602
|
+
xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;
|
|
2603
|
+
isPreviousElementTag = true;
|
|
1833
2604
|
continue;
|
|
1834
|
-
} else if (
|
|
1835
|
-
const
|
|
1836
|
-
|
|
1837
|
-
|
|
2605
|
+
} else if (tagName[0] === "?") {
|
|
2606
|
+
const attStr2 = attr_to_str(tagObj[":@"], options);
|
|
2607
|
+
const tempInd = tagName === "?xml" ? "" : indentation;
|
|
2608
|
+
let piTextNodeName = tagObj[tagName][0][options.textNodeName];
|
|
2609
|
+
piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : "";
|
|
2610
|
+
xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr2}?>`;
|
|
2611
|
+
isPreviousElementTag = true;
|
|
1838
2612
|
continue;
|
|
1839
2613
|
}
|
|
1840
|
-
let
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
2614
|
+
let newIdentation = indentation;
|
|
2615
|
+
if (newIdentation !== "") {
|
|
2616
|
+
newIdentation += options.indentBy;
|
|
2617
|
+
}
|
|
2618
|
+
const attStr = attr_to_str(tagObj[":@"], options);
|
|
2619
|
+
const tagStart = indentation + `<${tagName}${attStr}`;
|
|
2620
|
+
const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
|
|
2621
|
+
if (options.unpairedTags.indexOf(tagName) !== -1) {
|
|
2622
|
+
if (options.suppressUnpairedNode)
|
|
2623
|
+
xmlStr += tagStart + ">";
|
|
2624
|
+
else
|
|
2625
|
+
xmlStr += tagStart + "/>";
|
|
2626
|
+
} else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
|
|
2627
|
+
xmlStr += tagStart + "/>";
|
|
2628
|
+
} else if (tagValue && tagValue.endsWith(">")) {
|
|
2629
|
+
xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
|
|
2630
|
+
} else {
|
|
2631
|
+
xmlStr += tagStart + ">";
|
|
2632
|
+
if (tagValue && indentation !== "" && (tagValue.includes("/>") || tagValue.includes("</"))) {
|
|
2633
|
+
xmlStr += indentation + options.indentBy + tagValue + indentation;
|
|
2634
|
+
} else {
|
|
2635
|
+
xmlStr += tagValue;
|
|
2636
|
+
}
|
|
2637
|
+
xmlStr += `</${tagName}>`;
|
|
2638
|
+
}
|
|
2639
|
+
isPreviousElementTag = true;
|
|
1844
2640
|
}
|
|
1845
|
-
return
|
|
2641
|
+
return xmlStr;
|
|
1846
2642
|
}
|
|
1847
|
-
function
|
|
1848
|
-
const
|
|
1849
|
-
for (let
|
|
1850
|
-
const
|
|
1851
|
-
if (
|
|
1852
|
-
|
|
2643
|
+
function propName(obj) {
|
|
2644
|
+
const keys = Object.keys(obj);
|
|
2645
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2646
|
+
const key = keys[i];
|
|
2647
|
+
if (!obj.hasOwnProperty(key))
|
|
2648
|
+
continue;
|
|
2649
|
+
if (key !== ":@")
|
|
2650
|
+
return key;
|
|
1853
2651
|
}
|
|
1854
2652
|
}
|
|
1855
|
-
function
|
|
1856
|
-
let
|
|
1857
|
-
if (
|
|
1858
|
-
for (let
|
|
1859
|
-
if (!
|
|
2653
|
+
function attr_to_str(attrMap, options) {
|
|
2654
|
+
let attrStr = "";
|
|
2655
|
+
if (attrMap && !options.ignoreAttributes) {
|
|
2656
|
+
for (let attr in attrMap) {
|
|
2657
|
+
if (!attrMap.hasOwnProperty(attr))
|
|
1860
2658
|
continue;
|
|
1861
|
-
let
|
|
1862
|
-
|
|
2659
|
+
let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
|
|
2660
|
+
attrVal = replaceEntitiesValue(attrVal, options);
|
|
2661
|
+
if (attrVal === true && options.suppressBooleanAttributes) {
|
|
2662
|
+
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
|
|
2663
|
+
} else {
|
|
2664
|
+
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${attrVal}"`;
|
|
2665
|
+
}
|
|
1863
2666
|
}
|
|
1864
|
-
|
|
2667
|
+
}
|
|
2668
|
+
return attrStr;
|
|
1865
2669
|
}
|
|
1866
|
-
function
|
|
1867
|
-
|
|
1868
|
-
let
|
|
1869
|
-
for (let
|
|
1870
|
-
if (
|
|
1871
|
-
return
|
|
1872
|
-
|
|
2670
|
+
function isStopNode(jPath, options) {
|
|
2671
|
+
jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
|
|
2672
|
+
let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
|
|
2673
|
+
for (let index in options.stopNodes) {
|
|
2674
|
+
if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName)
|
|
2675
|
+
return true;
|
|
2676
|
+
}
|
|
2677
|
+
return false;
|
|
1873
2678
|
}
|
|
1874
|
-
function
|
|
1875
|
-
if (
|
|
1876
|
-
for (let
|
|
1877
|
-
const
|
|
1878
|
-
|
|
2679
|
+
function replaceEntitiesValue(textValue, options) {
|
|
2680
|
+
if (textValue && textValue.length > 0 && options.processEntities) {
|
|
2681
|
+
for (let i = 0; i < options.entities.length; i++) {
|
|
2682
|
+
const entity = options.entities[i];
|
|
2683
|
+
textValue = textValue.replace(entity.regex, entity.val);
|
|
1879
2684
|
}
|
|
1880
|
-
|
|
2685
|
+
}
|
|
2686
|
+
return textValue;
|
|
1881
2687
|
}
|
|
1882
|
-
var
|
|
1883
|
-
const
|
|
2688
|
+
var orderedJs2Xml = toXml;
|
|
2689
|
+
const buildFromOrderedJs = orderedJs2Xml;
|
|
2690
|
+
const defaultOptions = {
|
|
1884
2691
|
attributeNamePrefix: "@_",
|
|
1885
|
-
attributesGroupName:
|
|
2692
|
+
attributesGroupName: false,
|
|
1886
2693
|
textNodeName: "#text",
|
|
1887
|
-
ignoreAttributes:
|
|
1888
|
-
cdataPropName:
|
|
1889
|
-
format:
|
|
2694
|
+
ignoreAttributes: true,
|
|
2695
|
+
cdataPropName: false,
|
|
2696
|
+
format: false,
|
|
1890
2697
|
indentBy: " ",
|
|
1891
|
-
suppressEmptyNode:
|
|
1892
|
-
suppressUnpairedNode:
|
|
1893
|
-
suppressBooleanAttributes:
|
|
1894
|
-
tagValueProcessor: function(
|
|
1895
|
-
return
|
|
2698
|
+
suppressEmptyNode: false,
|
|
2699
|
+
suppressUnpairedNode: true,
|
|
2700
|
+
suppressBooleanAttributes: true,
|
|
2701
|
+
tagValueProcessor: function(key, a) {
|
|
2702
|
+
return a;
|
|
1896
2703
|
},
|
|
1897
|
-
attributeValueProcessor: function(
|
|
1898
|
-
return
|
|
2704
|
+
attributeValueProcessor: function(attrName, a) {
|
|
2705
|
+
return a;
|
|
1899
2706
|
},
|
|
1900
|
-
preserveOrder:
|
|
1901
|
-
commentPropName:
|
|
2707
|
+
preserveOrder: false,
|
|
2708
|
+
commentPropName: false,
|
|
1902
2709
|
unpairedTags: [],
|
|
1903
2710
|
entities: [
|
|
1904
2711
|
{ regex: new RegExp("&", "g"), val: "&" },
|
|
@@ -1908,126 +2715,240 @@ const Vt = Ft, St = {
|
|
|
1908
2715
|
{ regex: new RegExp("'", "g"), val: "'" },
|
|
1909
2716
|
{ regex: new RegExp('"', "g"), val: """ }
|
|
1910
2717
|
],
|
|
1911
|
-
processEntities:
|
|
2718
|
+
processEntities: true,
|
|
1912
2719
|
stopNodes: [],
|
|
1913
2720
|
// transformTagName: false,
|
|
1914
2721
|
// transformAttributeName: false,
|
|
1915
|
-
oneListGroup:
|
|
2722
|
+
oneListGroup: false
|
|
1916
2723
|
};
|
|
1917
|
-
function
|
|
1918
|
-
this.options = Object.assign({},
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
2724
|
+
function Builder(options) {
|
|
2725
|
+
this.options = Object.assign({}, defaultOptions, options);
|
|
2726
|
+
if (this.options.ignoreAttributes || this.options.attributesGroupName) {
|
|
2727
|
+
this.isAttribute = function() {
|
|
2728
|
+
return false;
|
|
2729
|
+
};
|
|
2730
|
+
} else {
|
|
2731
|
+
this.attrPrefixLen = this.options.attributeNamePrefix.length;
|
|
2732
|
+
this.isAttribute = isAttribute;
|
|
2733
|
+
}
|
|
2734
|
+
this.processTextOrObjNode = processTextOrObjNode;
|
|
2735
|
+
if (this.options.format) {
|
|
2736
|
+
this.indentate = indentate;
|
|
2737
|
+
this.tagEndChar = ">\n";
|
|
2738
|
+
this.newLine = "\n";
|
|
2739
|
+
} else {
|
|
2740
|
+
this.indentate = function() {
|
|
2741
|
+
return "";
|
|
2742
|
+
};
|
|
2743
|
+
this.tagEndChar = ">";
|
|
2744
|
+
this.newLine = "";
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
Builder.prototype.build = function(jObj) {
|
|
2748
|
+
if (this.options.preserveOrder) {
|
|
2749
|
+
return buildFromOrderedJs(jObj, this.options);
|
|
2750
|
+
} else {
|
|
2751
|
+
if (Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) {
|
|
2752
|
+
jObj = {
|
|
2753
|
+
[this.options.arrayNodeName]: jObj
|
|
2754
|
+
};
|
|
2755
|
+
}
|
|
2756
|
+
return this.j2x(jObj, 0).val;
|
|
2757
|
+
}
|
|
1930
2758
|
};
|
|
1931
|
-
|
|
1932
|
-
let
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
2759
|
+
Builder.prototype.j2x = function(jObj, level) {
|
|
2760
|
+
let attrStr = "";
|
|
2761
|
+
let val2 = "";
|
|
2762
|
+
for (let key in jObj) {
|
|
2763
|
+
if (!Object.prototype.hasOwnProperty.call(jObj, key))
|
|
2764
|
+
continue;
|
|
2765
|
+
if (typeof jObj[key] === "undefined") {
|
|
2766
|
+
if (this.isAttribute(key)) {
|
|
2767
|
+
val2 += "";
|
|
2768
|
+
}
|
|
2769
|
+
} else if (jObj[key] === null) {
|
|
2770
|
+
if (this.isAttribute(key)) {
|
|
2771
|
+
val2 += "";
|
|
2772
|
+
} else if (key[0] === "?") {
|
|
2773
|
+
val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
|
|
2774
|
+
} else {
|
|
2775
|
+
val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
2776
|
+
}
|
|
2777
|
+
} else if (jObj[key] instanceof Date) {
|
|
2778
|
+
val2 += this.buildTextValNode(jObj[key], key, "", level);
|
|
2779
|
+
} else if (typeof jObj[key] !== "object") {
|
|
2780
|
+
const attr = this.isAttribute(key);
|
|
2781
|
+
if (attr) {
|
|
2782
|
+
attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
|
|
2783
|
+
} else {
|
|
2784
|
+
if (key === this.options.textNodeName) {
|
|
2785
|
+
let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
|
|
2786
|
+
val2 += this.replaceEntitiesValue(newval);
|
|
2787
|
+
} else {
|
|
2788
|
+
val2 += this.buildTextValNode(jObj[key], key, "", level);
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
} else if (Array.isArray(jObj[key])) {
|
|
2792
|
+
const arrLen = jObj[key].length;
|
|
2793
|
+
let listTagVal = "";
|
|
2794
|
+
for (let j = 0; j < arrLen; j++) {
|
|
2795
|
+
const item = jObj[key][j];
|
|
2796
|
+
if (typeof item === "undefined")
|
|
2797
|
+
;
|
|
2798
|
+
else if (item === null) {
|
|
2799
|
+
if (key[0] === "?")
|
|
2800
|
+
val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
|
|
2801
|
+
else
|
|
2802
|
+
val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
2803
|
+
} else if (typeof item === "object") {
|
|
2804
|
+
if (this.options.oneListGroup) {
|
|
2805
|
+
listTagVal += this.j2x(item, level + 1).val;
|
|
2806
|
+
} else {
|
|
2807
|
+
listTagVal += this.processTextOrObjNode(item, key, level);
|
|
2808
|
+
}
|
|
2809
|
+
} else {
|
|
2810
|
+
listTagVal += this.buildTextValNode(item, key, "", level);
|
|
1956
2811
|
}
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
2812
|
+
}
|
|
2813
|
+
if (this.options.oneListGroup) {
|
|
2814
|
+
listTagVal = this.buildObjectNode(listTagVal, key, "", level);
|
|
2815
|
+
}
|
|
2816
|
+
val2 += listTagVal;
|
|
2817
|
+
} else {
|
|
2818
|
+
if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
|
|
2819
|
+
const Ks = Object.keys(jObj[key]);
|
|
2820
|
+
const L = Ks.length;
|
|
2821
|
+
for (let j = 0; j < L; j++) {
|
|
2822
|
+
attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
|
|
2823
|
+
}
|
|
2824
|
+
} else {
|
|
2825
|
+
val2 += this.processTextOrObjNode(jObj[key], key, level);
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
return { attrStr, val: val2 };
|
|
1965
2830
|
};
|
|
1966
|
-
|
|
1967
|
-
|
|
2831
|
+
Builder.prototype.buildAttrPairStr = function(attrName, val2) {
|
|
2832
|
+
val2 = this.options.attributeValueProcessor(attrName, "" + val2);
|
|
2833
|
+
val2 = this.replaceEntitiesValue(val2);
|
|
2834
|
+
if (this.options.suppressBooleanAttributes && val2 === "true") {
|
|
2835
|
+
return " " + attrName;
|
|
2836
|
+
} else
|
|
2837
|
+
return " " + attrName + '="' + val2 + '"';
|
|
1968
2838
|
};
|
|
1969
|
-
function
|
|
1970
|
-
const
|
|
1971
|
-
|
|
2839
|
+
function processTextOrObjNode(object, key, level) {
|
|
2840
|
+
const result = this.j2x(object, level + 1);
|
|
2841
|
+
if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
|
|
2842
|
+
return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
|
|
2843
|
+
} else {
|
|
2844
|
+
return this.buildObjectNode(result.val, key, result.attrStr, level);
|
|
2845
|
+
}
|
|
1972
2846
|
}
|
|
1973
|
-
|
|
1974
|
-
if (
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2847
|
+
Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
|
|
2848
|
+
if (val2 === "") {
|
|
2849
|
+
if (key[0] === "?")
|
|
2850
|
+
return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
|
|
2851
|
+
else {
|
|
2852
|
+
return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
|
|
2853
|
+
}
|
|
2854
|
+
} else {
|
|
2855
|
+
let tagEndExp = "</" + key + this.tagEndChar;
|
|
2856
|
+
let piClosingChar = "";
|
|
2857
|
+
if (key[0] === "?") {
|
|
2858
|
+
piClosingChar = "?";
|
|
2859
|
+
tagEndExp = "";
|
|
2860
|
+
}
|
|
2861
|
+
if ((attrStr || attrStr === "") && val2.indexOf("<") === -1) {
|
|
2862
|
+
return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val2 + tagEndExp;
|
|
2863
|
+
} else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
|
|
2864
|
+
return this.indentate(level) + `<!--${val2}-->` + this.newLine;
|
|
2865
|
+
} else {
|
|
2866
|
+
return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val2 + this.indentate(level) + tagEndExp;
|
|
2867
|
+
}
|
|
1979
2868
|
}
|
|
1980
2869
|
};
|
|
1981
|
-
|
|
1982
|
-
let
|
|
1983
|
-
|
|
2870
|
+
Builder.prototype.closeTag = function(key) {
|
|
2871
|
+
let closeTag = "";
|
|
2872
|
+
if (this.options.unpairedTags.indexOf(key) !== -1) {
|
|
2873
|
+
if (!this.options.suppressUnpairedNode)
|
|
2874
|
+
closeTag = "/";
|
|
2875
|
+
} else if (this.options.suppressEmptyNode) {
|
|
2876
|
+
closeTag = "/";
|
|
2877
|
+
} else {
|
|
2878
|
+
closeTag = `></${key}`;
|
|
2879
|
+
}
|
|
2880
|
+
return closeTag;
|
|
1984
2881
|
};
|
|
1985
|
-
|
|
1986
|
-
if (this.options.cdataPropName !==
|
|
1987
|
-
return this.indentate(
|
|
1988
|
-
if (this.options.commentPropName !==
|
|
1989
|
-
return this.indentate(
|
|
1990
|
-
if (
|
|
1991
|
-
return this.indentate(
|
|
1992
|
-
{
|
|
1993
|
-
let
|
|
1994
|
-
|
|
2882
|
+
Builder.prototype.buildTextValNode = function(val2, key, attrStr, level) {
|
|
2883
|
+
if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
|
|
2884
|
+
return this.indentate(level) + `<![CDATA[${val2}]]>` + this.newLine;
|
|
2885
|
+
} else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
|
|
2886
|
+
return this.indentate(level) + `<!--${val2}-->` + this.newLine;
|
|
2887
|
+
} else if (key[0] === "?") {
|
|
2888
|
+
return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
|
|
2889
|
+
} else {
|
|
2890
|
+
let textValue = this.options.tagValueProcessor(key, val2);
|
|
2891
|
+
textValue = this.replaceEntitiesValue(textValue);
|
|
2892
|
+
if (textValue === "") {
|
|
2893
|
+
return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
|
|
2894
|
+
} else {
|
|
2895
|
+
return this.indentate(level) + "<" + key + attrStr + ">" + textValue + "</" + key + this.tagEndChar;
|
|
2896
|
+
}
|
|
1995
2897
|
}
|
|
1996
2898
|
};
|
|
1997
|
-
|
|
1998
|
-
if (
|
|
1999
|
-
for (let
|
|
2000
|
-
const
|
|
2001
|
-
|
|
2899
|
+
Builder.prototype.replaceEntitiesValue = function(textValue) {
|
|
2900
|
+
if (textValue && textValue.length > 0 && this.options.processEntities) {
|
|
2901
|
+
for (let i = 0; i < this.options.entities.length; i++) {
|
|
2902
|
+
const entity = this.options.entities[i];
|
|
2903
|
+
textValue = textValue.replace(entity.regex, entity.val);
|
|
2002
2904
|
}
|
|
2003
|
-
|
|
2905
|
+
}
|
|
2906
|
+
return textValue;
|
|
2004
2907
|
};
|
|
2005
|
-
function
|
|
2006
|
-
return this.options.indentBy.repeat(
|
|
2007
|
-
}
|
|
2008
|
-
function
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2908
|
+
function indentate(level) {
|
|
2909
|
+
return this.options.indentBy.repeat(level);
|
|
2910
|
+
}
|
|
2911
|
+
function isAttribute(name) {
|
|
2912
|
+
if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
|
|
2913
|
+
return name.substr(this.attrPrefixLen);
|
|
2914
|
+
} else {
|
|
2915
|
+
return false;
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
var json2xml = Builder;
|
|
2919
|
+
const validator = validator$2;
|
|
2920
|
+
const XMLParser2 = XMLParser_1;
|
|
2921
|
+
const XMLBuilder = json2xml;
|
|
2922
|
+
var fxp = {
|
|
2923
|
+
XMLParser: XMLParser2,
|
|
2924
|
+
XMLValidator: validator,
|
|
2925
|
+
XMLBuilder
|
|
2017
2926
|
};
|
|
2018
|
-
function
|
|
2019
|
-
if (typeof
|
|
2020
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2927
|
+
function isSvg(string) {
|
|
2928
|
+
if (typeof string !== "string") {
|
|
2929
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
2930
|
+
}
|
|
2931
|
+
string = string.trim();
|
|
2932
|
+
if (string.length === 0) {
|
|
2933
|
+
return false;
|
|
2934
|
+
}
|
|
2935
|
+
if (fxp.XMLValidator.validate(string) !== true) {
|
|
2936
|
+
return false;
|
|
2937
|
+
}
|
|
2938
|
+
let jsonObject;
|
|
2939
|
+
const parser = new fxp.XMLParser();
|
|
2025
2940
|
try {
|
|
2026
|
-
|
|
2941
|
+
jsonObject = parser.parse(string);
|
|
2027
2942
|
} catch {
|
|
2028
|
-
return
|
|
2943
|
+
return false;
|
|
2944
|
+
}
|
|
2945
|
+
if (!jsonObject) {
|
|
2946
|
+
return false;
|
|
2947
|
+
}
|
|
2948
|
+
if (!Object.keys(jsonObject).some((x) => x.toLowerCase() === "svg")) {
|
|
2949
|
+
return false;
|
|
2029
2950
|
}
|
|
2030
|
-
return
|
|
2951
|
+
return true;
|
|
2031
2952
|
}
|
|
2032
2953
|
/**
|
|
2033
2954
|
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
@@ -2050,10 +2971,11 @@ function Ut(e) {
|
|
|
2050
2971
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
2051
2972
|
*
|
|
2052
2973
|
*/
|
|
2053
|
-
class
|
|
2974
|
+
class View {
|
|
2054
2975
|
_view;
|
|
2055
|
-
constructor(
|
|
2056
|
-
|
|
2976
|
+
constructor(view) {
|
|
2977
|
+
isValidView(view);
|
|
2978
|
+
this._view = view;
|
|
2057
2979
|
}
|
|
2058
2980
|
get id() {
|
|
2059
2981
|
return this._view.id;
|
|
@@ -2076,20 +2998,20 @@ class pr {
|
|
|
2076
2998
|
get icon() {
|
|
2077
2999
|
return this._view.icon;
|
|
2078
3000
|
}
|
|
2079
|
-
set icon(
|
|
2080
|
-
this._view.icon =
|
|
3001
|
+
set icon(icon) {
|
|
3002
|
+
this._view.icon = icon;
|
|
2081
3003
|
}
|
|
2082
3004
|
get order() {
|
|
2083
3005
|
return this._view.order;
|
|
2084
3006
|
}
|
|
2085
|
-
set order(
|
|
2086
|
-
this._view.order =
|
|
3007
|
+
set order(order) {
|
|
3008
|
+
this._view.order = order;
|
|
2087
3009
|
}
|
|
2088
3010
|
get params() {
|
|
2089
3011
|
return this._view.params;
|
|
2090
3012
|
}
|
|
2091
|
-
set params(
|
|
2092
|
-
this._view.params =
|
|
3013
|
+
set params(params) {
|
|
3014
|
+
this._view.params = params;
|
|
2093
3015
|
}
|
|
2094
3016
|
get columns() {
|
|
2095
3017
|
return this._view.columns;
|
|
@@ -2106,40 +3028,55 @@ class pr {
|
|
|
2106
3028
|
get expanded() {
|
|
2107
3029
|
return this._view.expanded;
|
|
2108
3030
|
}
|
|
2109
|
-
set expanded(
|
|
2110
|
-
this._view.expanded =
|
|
3031
|
+
set expanded(expanded) {
|
|
3032
|
+
this._view.expanded = expanded;
|
|
2111
3033
|
}
|
|
2112
3034
|
get defaultSortKey() {
|
|
2113
3035
|
return this._view.defaultSortKey;
|
|
2114
3036
|
}
|
|
2115
3037
|
}
|
|
2116
|
-
const
|
|
2117
|
-
if (!
|
|
3038
|
+
const isValidView = function(view) {
|
|
3039
|
+
if (!view.id || typeof view.id !== "string") {
|
|
2118
3040
|
throw new Error("View id is required and must be a string");
|
|
2119
|
-
|
|
3041
|
+
}
|
|
3042
|
+
if (!view.name || typeof view.name !== "string") {
|
|
2120
3043
|
throw new Error("View name is required and must be a string");
|
|
2121
|
-
|
|
3044
|
+
}
|
|
3045
|
+
if (view.columns && view.columns.length > 0 && (!view.caption || typeof view.caption !== "string")) {
|
|
2122
3046
|
throw new Error("View caption is required for top-level views and must be a string");
|
|
2123
|
-
|
|
3047
|
+
}
|
|
3048
|
+
if (!view.getContents || typeof view.getContents !== "function") {
|
|
2124
3049
|
throw new Error("View getContents is required and must be a function");
|
|
2125
|
-
|
|
3050
|
+
}
|
|
3051
|
+
if (!view.icon || typeof view.icon !== "string" || !isSvg(view.icon)) {
|
|
2126
3052
|
throw new Error("View icon is required and must be a valid svg string");
|
|
2127
|
-
|
|
3053
|
+
}
|
|
3054
|
+
if (!("order" in view) || typeof view.order !== "number") {
|
|
2128
3055
|
throw new Error("View order is required and must be a number");
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
3056
|
+
}
|
|
3057
|
+
if (view.columns) {
|
|
3058
|
+
view.columns.forEach((column) => {
|
|
3059
|
+
if (!(column instanceof Column)) {
|
|
3060
|
+
throw new Error("View columns must be an array of Column. Invalid column found");
|
|
3061
|
+
}
|
|
3062
|
+
});
|
|
3063
|
+
}
|
|
3064
|
+
if (view.emptyView && typeof view.emptyView !== "function") {
|
|
2133
3065
|
throw new Error("View emptyView must be a function");
|
|
2134
|
-
|
|
3066
|
+
}
|
|
3067
|
+
if (view.parent && typeof view.parent !== "string") {
|
|
2135
3068
|
throw new Error("View parent must be a string");
|
|
2136
|
-
|
|
3069
|
+
}
|
|
3070
|
+
if ("sticky" in view && typeof view.sticky !== "boolean") {
|
|
2137
3071
|
throw new Error("View sticky must be a boolean");
|
|
2138
|
-
|
|
3072
|
+
}
|
|
3073
|
+
if ("expanded" in view && typeof view.expanded !== "boolean") {
|
|
2139
3074
|
throw new Error("View expanded must be a boolean");
|
|
2140
|
-
|
|
3075
|
+
}
|
|
3076
|
+
if (view.defaultSortKey && typeof view.defaultSortKey !== "string") {
|
|
2141
3077
|
throw new Error("View defaultSortKey must be a string");
|
|
2142
|
-
|
|
3078
|
+
}
|
|
3079
|
+
return true;
|
|
2143
3080
|
};
|
|
2144
3081
|
/**
|
|
2145
3082
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
@@ -2163,48 +3100,60 @@ const Gt = function(e) {
|
|
|
2163
3100
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
2164
3101
|
*
|
|
2165
3102
|
*/
|
|
2166
|
-
const
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
3103
|
+
const addNewFileMenuEntry = function(entry) {
|
|
3104
|
+
const newFileMenu = getNewFileMenu();
|
|
3105
|
+
return newFileMenu.registerEntry(entry);
|
|
3106
|
+
};
|
|
3107
|
+
const removeNewFileMenuEntry = function(entry) {
|
|
3108
|
+
const newFileMenu = getNewFileMenu();
|
|
3109
|
+
return newFileMenu.unregisterEntry(entry);
|
|
3110
|
+
};
|
|
3111
|
+
const getNewFileMenuEntries = function(context) {
|
|
3112
|
+
const newFileMenu = getNewFileMenu();
|
|
3113
|
+
return newFileMenu.getEntries(context).sort((a, b) => {
|
|
3114
|
+
if (a.order !== void 0 && b.order !== void 0 && a.order !== b.order) {
|
|
3115
|
+
return a.order - b.order;
|
|
3116
|
+
}
|
|
3117
|
+
return a.displayName.localeCompare(b.displayName, void 0, { numeric: true, sensitivity: "base" });
|
|
3118
|
+
});
|
|
2172
3119
|
};
|
|
2173
3120
|
export {
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
3121
|
+
Column,
|
|
3122
|
+
DefaultType,
|
|
3123
|
+
File,
|
|
3124
|
+
FileAction,
|
|
3125
|
+
FileType,
|
|
3126
|
+
Folder,
|
|
3127
|
+
Header,
|
|
3128
|
+
Navigation,
|
|
3129
|
+
NewMenuEntryCategory,
|
|
3130
|
+
Node,
|
|
3131
|
+
NodeStatus,
|
|
3132
|
+
Permission,
|
|
3133
|
+
View,
|
|
3134
|
+
addNewFileMenuEntry,
|
|
3135
|
+
davGetClient,
|
|
3136
|
+
davGetDefaultPropfind,
|
|
3137
|
+
davGetFavoritesReport,
|
|
3138
|
+
davGetRecentSearch,
|
|
3139
|
+
davParsePermissions,
|
|
3140
|
+
davRemoteURL,
|
|
3141
|
+
davResultToNode,
|
|
3142
|
+
davRootPath,
|
|
3143
|
+
defaultDavNamespaces,
|
|
3144
|
+
defaultDavProperties,
|
|
3145
|
+
formatFileSize,
|
|
3146
|
+
getDavNameSpaces,
|
|
3147
|
+
getDavProperties,
|
|
3148
|
+
getFavoriteNodes,
|
|
3149
|
+
getFileActions,
|
|
3150
|
+
getFileListHeaders,
|
|
3151
|
+
getNavigation,
|
|
3152
|
+
getNewFileMenuEntries,
|
|
3153
|
+
isFilenameValid,
|
|
3154
|
+
parseFileSize,
|
|
3155
|
+
registerDavProperty,
|
|
3156
|
+
registerFileAction,
|
|
3157
|
+
registerFileListHeaders,
|
|
3158
|
+
removeNewFileMenuEntry
|
|
2210
3159
|
};
|