GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(opencode,core): close audit-v12 wave I-A shell classification fin… · anomalyco/opencode@3f69dad

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • core
      • src/util
        • wildcard.ts
      • test
        • wildcard.test.ts
    • opencode
      • src/tool
        • shell.ts
      • test/tool
        • shell.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/src/util/wildcard.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/util/wildcard.ts
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ export function unquote(value: string) {
2323
let quote: "'" | '"' | undefined
2424
for (let index = 0; index < value.length; index++) {
2525
const char = value[index]
26+
// Bash deletes `\<newline>` line continuations before execution (`ca\<newline>t`
27+
// runs `cat`); single quotes keep the backslash, so exclude only those.
28+
if (char === "\\" && quote !== "'") {
29+
const next = value[index + 1]
30+
if (next === "\n") {
31+
index++
32+
continue
33+
}
34+
if (next === "\r" && value[index + 2] === "\n") {
35+
index += 2
36+
continue
37+
}
38+
}
2639
if (quote) {
2740
if (char === quote) {
2841
quote = undefined
Collapse file

‎packages/core/test/wildcard.test.ts‎

Copy file name to clipboardExpand all lines: packages/core/test/wildcard.test.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ describe("Wildcard.unquote", () => {
112112
expect(Wildcard.matchStrict('"cat" notes.txt', "cat *")).toBe(true)
113113
})
114114

115+
test("deletes backslash-newline line continuations like bash", () => {
116+
expect(Wildcard.unquote("ca\\\nt")).toBe("cat")
117+
expect(Wildcard.unquote("\\\ncat")).toBe("cat")
118+
expect(Wildcard.unquote('"a\\\nb"')).toBe("ab")
119+
expect(Wildcard.unquote("'a\\\nb'")).toBe("a\\\nb")
120+
})
121+
115122
if (process.platform !== "win32") {
116123
test("unescapes backslash traversal as the shell would", () => {
117124
expect(Wildcard.unquote("..\\/etc")).toBe("../etc")

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.