@@ -65448,8 +65448,10 @@ class Composer {
6544865448 }
6544965449 }
6545065450 if (afterDoc) {
65451- Array.prototype.push.apply(doc.errors, this.errors);
65452- Array.prototype.push.apply(doc.warnings, this.warnings);
65451+ for (let i = 0; i < this.errors.length; ++i)
65452+ doc.errors.push(this.errors[i]);
65453+ for (let i = 0; i < this.warnings.length; ++i)
65454+ doc.warnings.push(this.warnings[i]);
6545365455 }
6545465456 else {
6545565457 doc.errors = this.errors;
@@ -66381,7 +66383,7 @@ function doubleQuotedValue(source, onError) {
6638166383 next = source[++i + 1];
6638266384 }
6638366385 else if (next === 'x' || next === 'u' || next === 'U') {
66384- const length = { x: 2, u: 4, U : 8 }[next] ;
66386+ const length = next === 'x' ? 2 : next === 'u' ? 4 : 8;
6638566387 res += parseCharCode(source, i + 1, length, onError);
6638666388 i += length;
6638766389 }
@@ -66451,12 +66453,14 @@ function parseCharCode(source, offset, length, onError) {
6645166453 const cc = source.substr(offset, length);
6645266454 const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
6645366455 const code = ok ? parseInt(cc, 16) : NaN;
66454- if (isNaN(code)) {
66456+ try {
66457+ return String.fromCodePoint(code);
66458+ }
66459+ catch {
6645566460 const raw = source.substr(offset - 2, length + 2);
6645666461 onError(offset - 2, 'BAD_DQ_ESCAPE', `Invalid escape sequence ${raw}`);
6645766462 return raw;
6645866463 }
66459- return String.fromCodePoint(code);
6646066464}
6646166465
6646266466exports.resolveFlowScalar = resolveFlowScalar;
@@ -67708,6 +67712,8 @@ class Alias extends Node.NodeBase {
6770867712 * instance of the `source` anchor before this node.
6770967713 */
6771067714 resolve(doc, ctx) {
67715+ if (ctx?.maxAliasCount === 0)
67716+ throw new ReferenceError('Alias resolution is disabled');
6771167717 let nodes;
6771267718 if (ctx?.aliasResolveCache) {
6771367719 nodes = ctx.aliasResolveCache;
@@ -69395,7 +69401,7 @@ class Lexer {
6939569401 const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
6939669402 this.indentNext = this.indentValue + 1;
6939769403 this.indentValue += n;
69398- return yield* this.parseBlockStart() ;
69404+ return 'block-start' ;
6939969405 }
6940069406 return 'doc';
6940169407 }
@@ -69716,32 +69722,36 @@ class Lexer {
6971669722 return 0;
6971769723 }
6971869724 *pushIndicators() {
69719- switch (this.charAt(0)) {
69720- case '!':
69721- return ((yield* this.pushTag()) +
69722- (yield* this.pushSpaces(true)) +
69723- (yield* this.pushIndicators()));
69724- case '&':
69725- return ((yield* this.pushUntil(isNotAnchorChar)) +
69726- (yield* this.pushSpaces(true)) +
69727- (yield* this.pushIndicators()));
69728- case '-': // this is an error
69729- case '?': // this is an error outside flow collections
69730- case ':': {
69731- const inFlow = this.flowLevel > 0;
69732- const ch1 = this.charAt(1);
69733- if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
69734- if (!inFlow)
69735- this.indentNext = this.indentValue + 1;
69736- else if (this.flowKey)
69737- this.flowKey = false;
69738- return ((yield* this.pushCount(1)) +
69739- (yield* this.pushSpaces(true)) +
69740- (yield* this.pushIndicators()));
69725+ let n = 0;
69726+ loop: while (true) {
69727+ switch (this.charAt(0)) {
69728+ case '!':
69729+ n += yield* this.pushTag();
69730+ n += yield* this.pushSpaces(true);
69731+ continue loop;
69732+ case '&':
69733+ n += yield* this.pushUntil(isNotAnchorChar);
69734+ n += yield* this.pushSpaces(true);
69735+ continue loop;
69736+ case '-': // this is an error
69737+ case '?': // this is an error outside flow collections
69738+ case ':': {
69739+ const inFlow = this.flowLevel > 0;
69740+ const ch1 = this.charAt(1);
69741+ if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
69742+ if (!inFlow)
69743+ this.indentNext = this.indentValue + 1;
69744+ else if (this.flowKey)
69745+ this.flowKey = false;
69746+ n += yield* this.pushCount(1);
69747+ n += yield* this.pushSpaces(true);
69748+ continue loop;
69749+ }
6974169750 }
6974269751 }
69752+ break loop;
6974369753 }
69744- return 0 ;
69754+ return n ;
6974569755 }
6974669756 *pushTag() {
6974769757 if (this.charAt(1) === '<') {
@@ -69929,6 +69939,14 @@ function getFirstKeyStartProps(prev) {
6992969939 }
6993069940 return prev.splice(i, prev.length);
6993169941}
69942+ function arrayPushArray(target, source) {
69943+ // May exhaust call stack with large `source` array
69944+ if (source.length < 1e5)
69945+ Array.prototype.push.apply(target, source);
69946+ else
69947+ for (let i = 0; i < source.length; ++i)
69948+ target.push(source[i]);
69949+ }
6993269950function fixFlowSeqItems(fc) {
6993369951 if (fc.start.type === 'flow-seq-start') {
6993469952 for (const it of fc.items) {
@@ -69941,12 +69959,12 @@ function fixFlowSeqItems(fc) {
6994169959 delete it.key;
6994269960 if (isFlowToken(it.value)) {
6994369961 if (it.value.end)
69944- Array.prototype.push.apply (it.value.end, it.sep);
69962+ arrayPushArray (it.value.end, it.sep);
6994569963 else
6994669964 it.value.end = it.sep;
6994769965 }
6994869966 else
69949- Array.prototype.push.apply (it.start, it.sep);
69967+ arrayPushArray (it.start, it.sep);
6995069968 delete it.sep;
6995169969 }
6995269970 }
@@ -70366,7 +70384,7 @@ class Parser {
7036670384 const prev = map.items[map.items.length - 2];
7036770385 const end = prev?.value?.end;
7036870386 if (Array.isArray(end)) {
70369- Array.prototype.push.apply (end, it.start);
70387+ arrayPushArray (end, it.start);
7037070388 end.push(this.sourceToken);
7037170389 map.items.pop();
7037270390 return;
@@ -70581,7 +70599,7 @@ class Parser {
7058170599 const prev = seq.items[seq.items.length - 2];
7058270600 const end = prev?.value?.end;
7058370601 if (Array.isArray(end)) {
70584- Array.prototype.push.apply (end, it.start);
70602+ arrayPushArray (end, it.start);
7058570603 end.push(this.sourceToken);
7058670604 seq.items.pop();
7058770605 return;
@@ -71735,18 +71753,18 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
7173571753 merge.identify(key.value))) &&
7173671754 ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
7173771755function addMergeToJSMap(ctx, map, value) {
71738- value = ctx && identity.isAlias(value) ? value.resolve( ctx.doc) : value;
71739- if (identity.isSeq(value ))
71740- for (const it of value .items)
71756+ const source = resolveAliasValue( ctx, value) ;
71757+ if (identity.isSeq(source ))
71758+ for (const it of source .items)
7174171759 mergeValue(ctx, map, it);
71742- else if (Array.isArray(value ))
71743- for (const it of value )
71760+ else if (Array.isArray(source ))
71761+ for (const it of source )
7174471762 mergeValue(ctx, map, it);
7174571763 else
71746- mergeValue(ctx, map, value );
71764+ mergeValue(ctx, map, source );
7174771765}
7174871766function mergeValue(ctx, map, value) {
71749- const source = ctx && identity.isAlias(value) ? value.resolve( ctx.doc) : value;
71767+ const source = resolveAliasValue( ctx, value) ;
7175071768 if (!identity.isMap(source))
7175171769 throw new Error('Merge sources must be maps or map aliases');
7175271770 const srcMap = source.toJSON(null, ctx, Map);
@@ -71769,6 +71787,9 @@ function mergeValue(ctx, map, value) {
7176971787 }
7177071788 return map;
7177171789}
71790+ function resolveAliasValue(ctx, value) {
71791+ return ctx && identity.isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
71792+ }
7177271793
7177371794exports.addMergeToJSMap = addMergeToJSMap;
7177471795exports.isMergeKey = isMergeKey;
@@ -72823,7 +72844,8 @@ function stringifyNumber({ format, minFractionDigits, tag, value }) {
7282372844 if (!format &&
7282472845 minFractionDigits &&
7282572846 (!tag || tag === 'tag:yaml.org,2002:float') &&
72826- /^\d/.test(n)) {
72847+ /^-?\d/.test(n) &&
72848+ !n.includes('e')) {
7282772849 let i = n.indexOf('.');
7282872850 if (i < 0) {
7282972851 i = n.length;
0 commit comments