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