@poe-platform/safe-bash 0.1.503 → 0.1.505

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.
@@ -34178,7 +34178,7 @@ function printedSimpleLines(lists, separators, budget) {
34178
34178
  var IncompleteShellInput = class extends Error {
34179
34179
  };
34180
34180
  var Lexer2 = class {
34181
- constructor(budget, source2, depth, warnings = [], lineOffset = 0, byteLocale2 = false, documentLine, partial = false, lineIndex = new SourceLineIndex(source2, budget), sourceOffset = 0) {
34181
+ constructor(budget, source2, depth, warnings = [], lineOffset = 0, byteLocale2 = false, documentLine, partial = false, lineIndex = new SourceLineIndex(source2, budget), sourceOffset = 0, ordinaryBacktick = false) {
34182
34182
  this.budget = budget;
34183
34183
  this.source = source2;
34184
34184
  this.depth = depth;
@@ -34189,6 +34189,7 @@ var Lexer2 = class {
34189
34189
  this.partial = partial;
34190
34190
  this.lineIndex = lineIndex;
34191
34191
  this.sourceOffset = sourceOffset;
34192
+ this.ordinaryBacktick = ordinaryBacktick;
34192
34193
  if (depth > 64) throw new ShellSyntaxError("Syntax nesting exceeds 64", 0);
34193
34194
  }
34194
34195
  budget;
@@ -34201,6 +34202,7 @@ var Lexer2 = class {
34201
34202
  partial;
34202
34203
  lineIndex;
34203
34204
  sourceOffset;
34205
+ ordinaryBacktick;
34204
34206
  position = 0;
34205
34207
  operandDepth = 0;
34206
34208
  printedNewlineReduction = 0;
@@ -34621,7 +34623,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
34621
34623
  if (this.source[this.position] !== "`") this.error("Unterminated command substitution");
34622
34624
  this.position++;
34623
34625
  try {
34624
- parts2.push({ kind: "substitution", script: parseSource(source2, this.depth + this.operandDepth + 1, this.warnings, line - 1, this.byteLocale, this.budget), line, quoted: quoted2 });
34626
+ parts2.push({ kind: "substitution", script: parseSource(source2, this.depth + this.operandDepth + 1, this.warnings, line - 1, this.byteLocale, this.budget, this.documentLine === void 0), line, quoted: quoted2 });
34625
34627
  } catch (error) {
34626
34628
  if (this.documentLine === void 0 || !(error instanceof ShellSyntaxError) || /nesting|exceeds/u.test(error.reason)) throw error;
34627
34629
  this.budget.admit();
@@ -34713,11 +34715,20 @@ shell: command substitution: line ${line}: \`${sourceLine}'
34713
34715
  this.operandDepth--;
34714
34716
  }
34715
34717
  }
34716
- if (this.source[this.position] !== "}") this.error("Unterminated or unsupported parameter expansion");
34717
- this.position++;
34718
- const part = { kind: "variable", name: name2, quoted: quoted2, line, ...length ? { length } : {}, ...operator ? { operator, alternate } : {}, ...replacement ? { replacement } : {}, ...substring ? { substring } : {} };
34719
- if (selector) setArraySelector(part, selector);
34720
- parts2.push(part);
34718
+ if (this.source[this.position] !== "}") {
34719
+ let end = this.position;
34720
+ if (this.ordinaryBacktick && !selector && !operator && !substring && /^[a-zA-Z_]/u.test(name2) && !"^,@".includes(this.source[this.position] ?? "")) {
34721
+ while (end < this.source.length && !" \r\n$`'\"\\{}[]();|&<>".includes(this.source[end])) end++;
34722
+ }
34723
+ if (end === this.position || this.source[end] !== "}") this.error("Unterminated or unsupported parameter expansion");
34724
+ this.position = end + 1;
34725
+ parts2.push({ kind: "failed-parameter", source: this.source.slice(parameterStart, this.position), line, quoted: quoted2 });
34726
+ } else {
34727
+ this.position++;
34728
+ const part = { kind: "variable", name: name2, quoted: quoted2, line, ...length ? { length } : {}, ...operator ? { operator, alternate } : {}, ...replacement ? { replacement } : {}, ...substring ? { substring } : {} };
34729
+ if (selector) setArraySelector(part, selector);
34730
+ parts2.push(part);
34731
+ }
34721
34732
  } else {
34722
34733
  const name2 = /^(?:[a-zA-Z_][a-zA-Z_0-9]*|[?@*#0-9-])/u.exec(this.source.slice(this.position))?.[0];
34723
34734
  if (name2) {
@@ -34732,11 +34743,11 @@ shell: command substitution: line ${line}: \`${sourceLine}'
34732
34743
  }
34733
34744
  };
34734
34745
  var Parser4 = class {
34735
- constructor(budget, source2, depth, warnings = [], lineOffset = 0, position, byteLocale2 = false, partial = false, lineIndex = new SourceLineIndex(source2, budget), sourceOffset = 0) {
34746
+ constructor(budget, source2, depth, warnings = [], lineOffset = 0, position, byteLocale2 = false, partial = false, lineIndex = new SourceLineIndex(source2, budget), sourceOffset = 0, ordinaryBacktick = false) {
34736
34747
  this.budget = budget;
34737
34748
  if (position === void 0 && depth === 0 && source2.includes("\0")) throw new ShellSyntaxError("NUL bytes are not valid shell source", source2.indexOf("\0"));
34738
34749
  budget.admit();
34739
- this.lexer = new Lexer2(budget, source2, depth, warnings, lineOffset, byteLocale2, void 0, partial, lineIndex, sourceOffset);
34750
+ this.lexer = new Lexer2(budget, source2, depth, warnings, lineOffset, byteLocale2, void 0, partial, lineIndex, sourceOffset, ordinaryBacktick);
34740
34751
  this.lexer.position = position ?? 0;
34741
34752
  this.current = this.lexer.next();
34742
34753
  }
@@ -35133,9 +35144,9 @@ function parseShellInputUnit(source2, byteLocale2 = false, budget = new ParseBud
35133
35144
  throw error;
35134
35145
  }
35135
35146
  }
35136
- function parseSource(source2, depth, warnings, lineOffset, byteLocale2, budget) {
35147
+ function parseSource(source2, depth, warnings, lineOffset, byteLocale2, budget, ordinaryBacktick = false) {
35137
35148
  budget.admit();
35138
- const parser = new Parser4(budget, source2, depth, warnings, lineOffset, void 0, byteLocale2);
35149
+ const parser = new Parser4(budget, source2, depth, warnings, lineOffset, void 0, byteLocale2, false, void 0, 0, ordinaryBacktick);
35139
35150
  const script = parser.script();
35140
35151
  if (parser.current.kind !== "end") parser.error("Unexpected token");
35141
35152
  return script;
@@ -42699,6 +42710,7 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
42699
42710
  }
42700
42711
  async partValue(part, state, io, hereString) {
42701
42712
  this.signal.throwIfAborted();
42713
+ if (part.kind === "failed-parameter") throw new ExpansionFailure(`${part.source}: bad substitution`, io.diagnosticLine ?? part.line);
42702
42714
  if (part.kind === "failed-substitution") {
42703
42715
  if (state.depth >= this.budget.limits.maxSubstitutionDepth) this.budget.fail("maxSubstitutionDepth");
42704
42716
  await writeDiagnostic(io.stderr, part.diagnostic);