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