diff --git a/dist/restore/index.js b/dist/restore/index.js index 6e1608e..bf4a45d 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -88775,6 +88775,111 @@ class TomlError extends Error { } } +;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/util.js +/*! + * Copyright (c) Squirrel Chat et al., All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +function indexOfNewline(str, start = 0, end = str.length) { + let idx = str.indexOf('\n', start); + if (str[idx - 1] === '\r') + idx--; + return idx <= end ? idx : -1; +} +function skipComment(str, ptr) { + for (let i = ptr; i < str.length; i++) { + let c = str[i]; + if (c === '\n') + return i; + if (c === '\r' && str[i + 1] === '\n') + return i + 1; + if ((c < '\x20' && c !== '\t') || c === '\x7f') { + throw new TomlError('control characters are not allowed in comments', { + toml: str, + ptr: ptr, + }); + } + } + return str.length; +} +function skipVoid(str, ptr, banNewLines, banComments) { + let c; + while ((c = str[ptr]) === ' ' || c === '\t' || (!banNewLines && (c === '\n' || c === '\r' && str[ptr + 1] === '\n'))) + ptr++; + return banComments || c !== '#' + ? ptr + : skipVoid(str, skipComment(str, ptr), banNewLines); +} +function skipUntil(str, ptr, sep, end, banNewLines = false) { + if (!end) { + ptr = indexOfNewline(str, ptr); + return ptr < 0 ? str.length : ptr; + } + for (let i = ptr; i < str.length; i++) { + let c = str[i]; + if (c === '#') { + i = indexOfNewline(str, i); + } + else if (c === sep) { + return i + 1; + } + else if (c === end) { + return i; + } + else if (banNewLines && (c === '\n' || c === '\r' && str[i + 1] === '\n')) { + return i; + } + } + throw new TomlError('cannot find end of structure', { + toml: str, + ptr: ptr + }); +} +function getStringEnd(str, seek) { + let first = str[seek]; + let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] + ? str.slice(seek, seek + 3) + : first; + seek += target.length - 1; + do + seek = str.indexOf(target, ++seek); + while (seek > -1 && first !== "'" && str[seek - 1] === '\\' && str[seek - 2] !== '\\'); + if (seek > -1) { + seek += target.length; + if (target.length > 1) { + if (str[seek] === first) + seek++; + if (str[seek] === first) + seek++; + } + } + return seek; +} + ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/date.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -88827,7 +88932,7 @@ class TomlDate extends Date { else { offset = match[3] || null; date = date.toUpperCase(); - if (!offset) + if (!offset && hasTime) date += 'Z'; } } @@ -88902,111 +89007,6 @@ class TomlDate extends Date { } } -;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/util.js -/*! - * Copyright (c) Squirrel Chat et al., All rights reserved. - * SPDX-License-Identifier: BSD-3-Clause - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -function indexOfNewline(str, start = 0, end = str.length) { - let idx = str.indexOf('\n', start); - if (str[idx - 1] === '\r') - idx--; - return idx <= end ? idx : -1; -} -function skipComment(str, ptr) { - for (let i = ptr; i < str.length; i++) { - let c = str[i]; - if (c === '\n') - return i; - if (c === '\r' && str[i + 1] === '\n') - return i + 1; - if ((c < '\x20' && c !== '\t') || c === '\x7f') { - throw new TomlError('control characters are not allowed in comments', { - toml: str, - ptr: ptr, - }); - } - } - return str.length; -} -function skipVoid(str, ptr, banNewLines, banComments) { - let c; - while ((c = str[ptr]) === ' ' || c === '\t' || (!banNewLines && (c === '\n' || c === '\r' && str[ptr + 1] === '\n'))) - ptr++; - return banComments || c !== '#' - ? ptr - : skipVoid(str, skipComment(str, ptr), banNewLines); -} -function skipUntil(str, ptr, sep, end, banNewLines = false) { - if (!end) { - ptr = indexOfNewline(str, ptr); - return ptr < 0 ? str.length : ptr; - } - for (let i = ptr; i < str.length; i++) { - let c = str[i]; - if (c === '#') { - i = indexOfNewline(str, i); - } - else if (c === sep) { - return i + 1; - } - else if (c === end) { - return i; - } - else if (banNewLines && (c === '\n' || c === '\r' && str[i + 1] === '\n')) { - return i; - } - } - throw new TomlError('cannot find end of structure', { - toml: str, - ptr: ptr - }); -} -function getStringEnd(str, seek) { - let first = str[seek]; - let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] - ? str.slice(seek, seek + 3) - : first; - seek += target.length - 1; - do - seek = str.indexOf(target, ++seek); - while (seek > -1 && first !== "'" && str[seek - 1] === '\\' && str[seek - 2] !== '\\'); - if (seek > -1) { - seek += target.length; - if (target.length > 1) { - if (str[seek] === first) - seek++; - if (str[seek] === first) - seek++; - } - } - return seek; -} - ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/primitive.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -89234,12 +89234,18 @@ function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) { } return [trimmed, commentIdx]; } -function extractValue(str, ptr, end) { +function extractValue(str, ptr, end, depth) { + if (depth === 0) { + throw new TomlError('document contains excessively nested structures. aborting.', { + toml: str, + ptr: ptr + }); + } let c = str[ptr]; if (c === '[' || c === '{') { let [value, endPtr] = c === '[' - ? parseArray(str, ptr) - : parseInlineTable(str, ptr); + ? parseArray(str, ptr, depth) + : parseInlineTable(str, ptr, depth); let newPtr = skipUntil(str, endPtr, ',', end); if (end === '}') { let nextNewLine = indexOfNewline(str, endPtr, newPtr); @@ -89391,7 +89397,7 @@ function parseKey(str, ptr, end = '=') { } while (dot + 1 && dot < endPtr); return [parsed, skipVoid(str, endPtr + 1, true, true)]; } -function parseInlineTable(str, ptr) { +function parseInlineTable(str, ptr, depth) { let res = {}; let seen = new Set(); let c; @@ -89441,7 +89447,7 @@ function parseInlineTable(str, ptr) { ptr: ptr }); } - let [value, valueEndPtr] = extractValue(str, keyEndPtr, '}'); + let [value, valueEndPtr] = extractValue(str, keyEndPtr, '}', depth - 1); seen.add(value); t[k] = value; ptr = valueEndPtr; @@ -89462,7 +89468,7 @@ function parseInlineTable(str, ptr) { } return [res, ptr]; } -function parseArray(str, ptr) { +function parseArray(str, ptr, depth) { let res = []; let c; ptr++; @@ -89476,7 +89482,7 @@ function parseArray(str, ptr) { else if (c === '#') ptr = skipComment(str, ptr); else if (c !== ' ' && c !== '\t' && c !== '\n' && c !== '\r') { - let e = extractValue(str, ptr - 1, ']'); + let e = extractValue(str, ptr - 1, ']', depth - 1); res.push(e[0]); ptr = e[1]; } @@ -89586,7 +89592,8 @@ function peekTable(key, table, meta, type) { } return [k, t, state.c]; } -function parse(toml) { +function parse(toml, opts) { + let maxDepth = opts?.maxDepth ?? 1000; let res = {}; let meta = {}; let tbl = res; @@ -89624,7 +89631,7 @@ function parse(toml) { ptr: ptr, }); } - let v = extractValue(toml, k[1]); + let v = extractValue(toml, k[1], void 0, maxDepth); p[1][p[0]] = v[0]; ptr = v[1]; } @@ -89640,6 +89647,170 @@ function parse(toml) { return res; } +;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/stringify.js +/*! + * Copyright (c) Squirrel Chat et al., All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +let BARE_KEY = /^[a-z0-9-_]+$/i; +function extendedTypeOf(obj) { + let type = typeof obj; + if (type === 'object') { + if (Array.isArray(obj)) + return 'array'; + if (obj instanceof Date) + return 'date'; + } + return type; +} +function isArrayOfTables(obj) { + for (let i = 0; i < obj.length; i++) { + if (extendedTypeOf(obj[i]) !== 'object') + return false; + } + return obj.length != 0; +} +function formatString(s) { + return JSON.stringify(s).replace(/\x7f/g, '\\u007f'); +} +function stringifyValue(val, type, depth) { + if (depth === 0) { + throw new Error("Could not stringify the object: maximum object depth exceeded"); + } + if (type === 'number') { + if (isNaN(val)) + return 'nan'; + if (val === Infinity) + return 'inf'; + if (val === -Infinity) + return '-inf'; + return val.toString(); + } + if (type === 'bigint' || type === 'boolean') { + return val.toString(); + } + if (type === 'string') { + return formatString(val); + } + if (type === 'date') { + if (isNaN(val.getTime())) { + throw new TypeError('cannot serialize invalid date'); + } + return val.toISOString(); + } + if (type === 'object') { + return stringifyInlineTable(val, depth); + } + if (type === 'array') { + return stringifyArray(val, depth); + } +} +function stringifyInlineTable(obj, depth) { + let keys = Object.keys(obj); + if (keys.length === 0) + return '{}'; + let res = '{ '; + for (let i = 0; i < keys.length; i++) { + let k = keys[i]; + if (i) + res += ', '; + res += BARE_KEY.test(k) ? k : formatString(k); + res += ' = '; + res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1); + } + return res + ' }'; +} +function stringifyArray(array, depth) { + if (array.length === 0) + return '[]'; + let res = '[ '; + for (let i = 0; i < array.length; i++) { + if (i) + res += ', '; + if (array[i] === null || array[i] === void 0) { + throw new TypeError('arrays cannot contain null or undefined values'); + } + res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1); + } + return res + ' ]'; +} +function stringifyArrayTable(array, key, depth) { + if (depth === 0) { + throw new Error("Could not stringify the object: maximum object depth exceeded"); + } + let res = ''; + for (let i = 0; i < array.length; i++) { + res += `[[${key}]]\n`; + res += stringifyTable(array[i], key, depth); + res += '\n\n'; + } + return res; +} +function stringifyTable(obj, prefix, depth) { + if (depth === 0) { + throw new Error("Could not stringify the object: maximum object depth exceeded"); + } + let preamble = ''; + let tables = ''; + let keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + let k = keys[i]; + if (obj[k] !== null && obj[k] !== void 0) { + let type = extendedTypeOf(obj[k]); + if (type === 'symbol' || type === 'function') { + throw new TypeError(`cannot serialize values of type '${type}'`); + } + let key = BARE_KEY.test(k) ? k : formatString(k); + if (type === 'array' && isArrayOfTables(obj[k])) { + tables += stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1); + } + else if (type === 'object') { + let tblKey = prefix ? `${prefix}.${key}` : key; + tables += `[${tblKey}]\n`; + tables += stringifyTable(obj[k], tblKey, depth - 1); + tables += '\n\n'; + } + else { + preamble += key; + preamble += ' = '; + preamble += stringifyValue(obj[k], type, depth); + preamble += '\n'; + } + } + } + return `${preamble}\n${tables}`.trim(); +} +function stringify(obj, opts) { + if (extendedTypeOf(obj) !== 'object') { + throw new TypeError('stringify can only be called with an object'); + } + let maxDepth = opts?.maxDepth ?? 1000; + return stringifyTable(obj, '', maxDepth); +} + ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/index.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -89672,6 +89843,8 @@ function parse(toml) { +/* harmony default export */ const dist = ({ parse: parse, stringify: stringify, TomlDate: TomlDate, TomlError: TomlError }); + // EXTERNAL MODULE: ./node_modules/@actions/exec/lib/exec.js var exec = __nccwpck_require__(1514); diff --git a/dist/save/index.js b/dist/save/index.js index 9007694..f9f2aae 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -87417,6 +87417,111 @@ class TomlError extends Error { } } +;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/util.js +/*! + * Copyright (c) Squirrel Chat et al., All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +function indexOfNewline(str, start = 0, end = str.length) { + let idx = str.indexOf('\n', start); + if (str[idx - 1] === '\r') + idx--; + return idx <= end ? idx : -1; +} +function skipComment(str, ptr) { + for (let i = ptr; i < str.length; i++) { + let c = str[i]; + if (c === '\n') + return i; + if (c === '\r' && str[i + 1] === '\n') + return i + 1; + if ((c < '\x20' && c !== '\t') || c === '\x7f') { + throw new TomlError('control characters are not allowed in comments', { + toml: str, + ptr: ptr, + }); + } + } + return str.length; +} +function skipVoid(str, ptr, banNewLines, banComments) { + let c; + while ((c = str[ptr]) === ' ' || c === '\t' || (!banNewLines && (c === '\n' || c === '\r' && str[ptr + 1] === '\n'))) + ptr++; + return banComments || c !== '#' + ? ptr + : skipVoid(str, skipComment(str, ptr), banNewLines); +} +function skipUntil(str, ptr, sep, end, banNewLines = false) { + if (!end) { + ptr = indexOfNewline(str, ptr); + return ptr < 0 ? str.length : ptr; + } + for (let i = ptr; i < str.length; i++) { + let c = str[i]; + if (c === '#') { + i = indexOfNewline(str, i); + } + else if (c === sep) { + return i + 1; + } + else if (c === end) { + return i; + } + else if (banNewLines && (c === '\n' || c === '\r' && str[i + 1] === '\n')) { + return i; + } + } + throw new TomlError('cannot find end of structure', { + toml: str, + ptr: ptr + }); +} +function getStringEnd(str, seek) { + let first = str[seek]; + let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] + ? str.slice(seek, seek + 3) + : first; + seek += target.length - 1; + do + seek = str.indexOf(target, ++seek); + while (seek > -1 && first !== "'" && str[seek - 1] === '\\' && str[seek - 2] !== '\\'); + if (seek > -1) { + seek += target.length; + if (target.length > 1) { + if (str[seek] === first) + seek++; + if (str[seek] === first) + seek++; + } + } + return seek; +} + ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/date.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -87469,7 +87574,7 @@ class TomlDate extends Date { else { offset = match[3] || null; date = date.toUpperCase(); - if (!offset) + if (!offset && hasTime) date += 'Z'; } } @@ -87544,111 +87649,6 @@ class TomlDate extends Date { } } -;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/util.js -/*! - * Copyright (c) Squirrel Chat et al., All rights reserved. - * SPDX-License-Identifier: BSD-3-Clause - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -function indexOfNewline(str, start = 0, end = str.length) { - let idx = str.indexOf('\n', start); - if (str[idx - 1] === '\r') - idx--; - return idx <= end ? idx : -1; -} -function skipComment(str, ptr) { - for (let i = ptr; i < str.length; i++) { - let c = str[i]; - if (c === '\n') - return i; - if (c === '\r' && str[i + 1] === '\n') - return i + 1; - if ((c < '\x20' && c !== '\t') || c === '\x7f') { - throw new TomlError('control characters are not allowed in comments', { - toml: str, - ptr: ptr, - }); - } - } - return str.length; -} -function skipVoid(str, ptr, banNewLines, banComments) { - let c; - while ((c = str[ptr]) === ' ' || c === '\t' || (!banNewLines && (c === '\n' || c === '\r' && str[ptr + 1] === '\n'))) - ptr++; - return banComments || c !== '#' - ? ptr - : skipVoid(str, skipComment(str, ptr), banNewLines); -} -function skipUntil(str, ptr, sep, end, banNewLines = false) { - if (!end) { - ptr = indexOfNewline(str, ptr); - return ptr < 0 ? str.length : ptr; - } - for (let i = ptr; i < str.length; i++) { - let c = str[i]; - if (c === '#') { - i = indexOfNewline(str, i); - } - else if (c === sep) { - return i + 1; - } - else if (c === end) { - return i; - } - else if (banNewLines && (c === '\n' || c === '\r' && str[i + 1] === '\n')) { - return i; - } - } - throw new TomlError('cannot find end of structure', { - toml: str, - ptr: ptr - }); -} -function getStringEnd(str, seek) { - let first = str[seek]; - let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] - ? str.slice(seek, seek + 3) - : first; - seek += target.length - 1; - do - seek = str.indexOf(target, ++seek); - while (seek > -1 && first !== "'" && str[seek - 1] === '\\' && str[seek - 2] !== '\\'); - if (seek > -1) { - seek += target.length; - if (target.length > 1) { - if (str[seek] === first) - seek++; - if (str[seek] === first) - seek++; - } - } - return seek; -} - ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/primitive.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -87876,12 +87876,18 @@ function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) { } return [trimmed, commentIdx]; } -function extractValue(str, ptr, end) { +function extractValue(str, ptr, end, depth) { + if (depth === 0) { + throw new TomlError('document contains excessively nested structures. aborting.', { + toml: str, + ptr: ptr + }); + } let c = str[ptr]; if (c === '[' || c === '{') { let [value, endPtr] = c === '[' - ? parseArray(str, ptr) - : parseInlineTable(str, ptr); + ? parseArray(str, ptr, depth) + : parseInlineTable(str, ptr, depth); let newPtr = skipUntil(str, endPtr, ',', end); if (end === '}') { let nextNewLine = indexOfNewline(str, endPtr, newPtr); @@ -88033,7 +88039,7 @@ function parseKey(str, ptr, end = '=') { } while (dot + 1 && dot < endPtr); return [parsed, skipVoid(str, endPtr + 1, true, true)]; } -function parseInlineTable(str, ptr) { +function parseInlineTable(str, ptr, depth) { let res = {}; let seen = new Set(); let c; @@ -88083,7 +88089,7 @@ function parseInlineTable(str, ptr) { ptr: ptr }); } - let [value, valueEndPtr] = extractValue(str, keyEndPtr, '}'); + let [value, valueEndPtr] = extractValue(str, keyEndPtr, '}', depth - 1); seen.add(value); t[k] = value; ptr = valueEndPtr; @@ -88104,7 +88110,7 @@ function parseInlineTable(str, ptr) { } return [res, ptr]; } -function parseArray(str, ptr) { +function parseArray(str, ptr, depth) { let res = []; let c; ptr++; @@ -88118,7 +88124,7 @@ function parseArray(str, ptr) { else if (c === '#') ptr = skipComment(str, ptr); else if (c !== ' ' && c !== '\t' && c !== '\n' && c !== '\r') { - let e = extractValue(str, ptr - 1, ']'); + let e = extractValue(str, ptr - 1, ']', depth - 1); res.push(e[0]); ptr = e[1]; } @@ -88228,7 +88234,8 @@ function peekTable(key, table, meta, type) { } return [k, t, state.c]; } -function parse(toml) { +function parse(toml, opts) { + let maxDepth = opts?.maxDepth ?? 1000; let res = {}; let meta = {}; let tbl = res; @@ -88266,7 +88273,7 @@ function parse(toml) { ptr: ptr, }); } - let v = extractValue(toml, k[1]); + let v = extractValue(toml, k[1], void 0, maxDepth); p[1][p[0]] = v[0]; ptr = v[1]; } @@ -88282,6 +88289,170 @@ function parse(toml) { return res; } +;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/stringify.js +/*! + * Copyright (c) Squirrel Chat et al., All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +let BARE_KEY = /^[a-z0-9-_]+$/i; +function extendedTypeOf(obj) { + let type = typeof obj; + if (type === 'object') { + if (Array.isArray(obj)) + return 'array'; + if (obj instanceof Date) + return 'date'; + } + return type; +} +function isArrayOfTables(obj) { + for (let i = 0; i < obj.length; i++) { + if (extendedTypeOf(obj[i]) !== 'object') + return false; + } + return obj.length != 0; +} +function formatString(s) { + return JSON.stringify(s).replace(/\x7f/g, '\\u007f'); +} +function stringifyValue(val, type, depth) { + if (depth === 0) { + throw new Error("Could not stringify the object: maximum object depth exceeded"); + } + if (type === 'number') { + if (isNaN(val)) + return 'nan'; + if (val === Infinity) + return 'inf'; + if (val === -Infinity) + return '-inf'; + return val.toString(); + } + if (type === 'bigint' || type === 'boolean') { + return val.toString(); + } + if (type === 'string') { + return formatString(val); + } + if (type === 'date') { + if (isNaN(val.getTime())) { + throw new TypeError('cannot serialize invalid date'); + } + return val.toISOString(); + } + if (type === 'object') { + return stringifyInlineTable(val, depth); + } + if (type === 'array') { + return stringifyArray(val, depth); + } +} +function stringifyInlineTable(obj, depth) { + let keys = Object.keys(obj); + if (keys.length === 0) + return '{}'; + let res = '{ '; + for (let i = 0; i < keys.length; i++) { + let k = keys[i]; + if (i) + res += ', '; + res += BARE_KEY.test(k) ? k : formatString(k); + res += ' = '; + res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1); + } + return res + ' }'; +} +function stringifyArray(array, depth) { + if (array.length === 0) + return '[]'; + let res = '[ '; + for (let i = 0; i < array.length; i++) { + if (i) + res += ', '; + if (array[i] === null || array[i] === void 0) { + throw new TypeError('arrays cannot contain null or undefined values'); + } + res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1); + } + return res + ' ]'; +} +function stringifyArrayTable(array, key, depth) { + if (depth === 0) { + throw new Error("Could not stringify the object: maximum object depth exceeded"); + } + let res = ''; + for (let i = 0; i < array.length; i++) { + res += `[[${key}]]\n`; + res += stringifyTable(array[i], key, depth); + res += '\n\n'; + } + return res; +} +function stringifyTable(obj, prefix, depth) { + if (depth === 0) { + throw new Error("Could not stringify the object: maximum object depth exceeded"); + } + let preamble = ''; + let tables = ''; + let keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + let k = keys[i]; + if (obj[k] !== null && obj[k] !== void 0) { + let type = extendedTypeOf(obj[k]); + if (type === 'symbol' || type === 'function') { + throw new TypeError(`cannot serialize values of type '${type}'`); + } + let key = BARE_KEY.test(k) ? k : formatString(k); + if (type === 'array' && isArrayOfTables(obj[k])) { + tables += stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1); + } + else if (type === 'object') { + let tblKey = prefix ? `${prefix}.${key}` : key; + tables += `[${tblKey}]\n`; + tables += stringifyTable(obj[k], tblKey, depth - 1); + tables += '\n\n'; + } + else { + preamble += key; + preamble += ' = '; + preamble += stringifyValue(obj[k], type, depth); + preamble += '\n'; + } + } + } + return `${preamble}\n${tables}`.trim(); +} +function stringify(obj, opts) { + if (extendedTypeOf(obj) !== 'object') { + throw new TypeError('stringify can only be called with an object'); + } + let maxDepth = opts?.maxDepth ?? 1000; + return stringifyTable(obj, '', maxDepth); +} + ;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/index.js /*! * Copyright (c) Squirrel Chat et al., All rights reserved. @@ -88314,6 +88485,8 @@ function parse(toml) { +/* harmony default export */ const dist = ({ parse: parse, stringify: stringify, TomlDate: TomlDate, TomlError: TomlError }); + // EXTERNAL MODULE: ./node_modules/@actions/buildjet-cache/lib/cache.js var lib_cache = __nccwpck_require__(7551); diff --git a/package-lock.json b/package-lock.json index 5e111f4..b1eed04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@actions/glob": "^0.4.0", "@actions/io": "^1.1.3", "axios": "^1.6.2", - "smol-toml": "^1.1.4" + "smol-toml": "^1.3.1" }, "devDependencies": { "@vercel/ncc": "^0.38.1", @@ -607,12 +607,14 @@ } }, "node_modules/smol-toml": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.1.4.tgz", - "integrity": "sha512-Y0OT8HezWsTNeEOSVxDnKOW/AyNXHQ4BwJNbAXlLTF5wWsBvrcHhIkE5Rf8kQMLmgf7nDX3PVOlgC6/Aiggu3Q==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.3.1.tgz", + "integrity": "sha512-tEYNll18pPKHroYSmLLrksq233j021G0giwW7P3D24jC54pQ5W5BXMsQ/Mvw1OJCmEYDgY+lrzT+3nNUtoNfXQ==", "engines": { - "node": ">= 18", - "pnpm": ">= 8" + "node": ">= 18" + }, + "funding": { + "url": "https://github.com/sponsors/cyyynthia" } }, "node_modules/tr46": { diff --git a/package.json b/package.json index 3877178..20ba33c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@actions/exec": "^1.1.1", "@actions/glob": "^0.4.0", "@actions/io": "^1.1.3", - "smol-toml": "^1.1.4" + "smol-toml": "^1.3.1" }, "devDependencies": { "@vercel/ncc": "^0.38.1",