Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(frontend): keep '#' inside unquoted pasted/imported secret values
Devin AI139347e74285
diff --git a/frontend/src/components/utilities/parseSecrets.test.ts b/frontend/src/components/utilities/parseSecrets.test.tsindex a1423a83fb..39edd66b5c 100644--- a/frontend/src/components/utilities/parseSecrets.test.ts+++ b/frontend/src/components/utilities/parseSecrets.test.ts@@ -114,6 +114,24 @@ describe("parseDotEnv", () => {assert.equal(env.MULTI.value, "one\ntwo");assert.equal(env.BARE.value, "plain");});++ it("keeps a hash that is not preceded by whitespace in unquoted values", () => {+ const env = parseDotEnv(+ [+ "PASSWORD=abc#def",+ "URL=https://example.com/#/path",+ "HASH=#leading",+ "SPACED=one two#three # trailing",+ "EMPTY= # only a comment"+ ].join("\n")+ );++ assert.equal(env.PASSWORD.value, "abc#def");+ assert.equal(env.URL.value, "https://example.com/#/path");+ assert.equal(env.HASH.value, "#leading");+ assert.equal(env.SPACED.value, "one two#three");+ assert.equal(env.EMPTY.value, "");+ });});describe("parsePastedSecrets", () => {diff --git a/frontend/src/components/utilities/parseSecrets.ts b/frontend/src/components/utilities/parseSecrets.tsindex e7d32fcb1f..6e8b8ba421 100644--- a/frontend/src/components/utilities/parseSecrets.ts+++ b/frontend/src/components/utilities/parseSecrets.ts@@ -1,7 +1,8 @@import { isMap, isNode, isScalar, isSeq, parseDocument } from "yaml";+// Unquoted values end at a "#" preceded by whitespace, so "a#b" keeps its hash.const LINE =- /(?:^|^)\s*(?:export\s+)?([\w.:-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;+ /(?:^|^)\s*(?:export\s+)?([\w.:-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|\S(?:\S|\s+(?=[^\s#]))*)?\s*(?:#.*)?(?:$|$)/gm;const decodeSource = (src: ArrayBuffer | string) =>typeof src === "string" ? src : new TextDecoder("utf-8").decode(src);