Skip to content

fix(codersdk): reject trailing data after closing single quote in env import#27474

Open
dylanhuff-at-coder wants to merge 1 commit into
mainfrom
dylan/plat-240-fix-single-quote-trailing-data
Open

fix(codersdk): reject trailing data after closing single quote in env import#27474
dylanhuff-at-coder wants to merge 1 commit into
mainfrom
dylan/plat-240-fix-single-quote-trailing-data

Conversation

@dylanhuff-at-coder

Copy link
Copy Markdown
Contributor

The single-quote path of the dotenv parser in codersdk/usersecretsimport.go stripped the first and last characters of the value instead of scanning for the first closing quote the way the double-quote path does. Trailing data after a closed single-quoted value was silently folded into the secret (KEY='abc' # 'note' yielded abc' # 'note, KEY='a'b' yielded a'b), and KEY='abc' extra failed with the misleading message "missing closing single quote".

Replace quotedInner with singleQuotedInner, which mirrors doubleQuotedInner: it finds the first closing single quote, accepts only trailing whitespace after it, and reports unexpected data after closing single quote for anything else, keeping missing closing single quote for genuinely unterminated values.

Follow-up to a bug flagged in review of #26724: #26724 (comment)

This PR was authored by Coder Agents on behalf of @dylanhuff-at-coder.

… import

The single-quoted value path of the dotenv parser previously trimmed
trailing whitespace and stripped the first and last characters, so
values like KEY='abc' # 'note' or KEY='a'b' silently swallowed data
after the first closing quote, and KEY='abc' extra reported a
misleading missing-quote error. The parser now scans for the first
closing single quote, mirroring the double-quote path: whitespace-only
trailers are accepted and any other trailing data is rejected with an
unexpected-data error.

Flagged in review of #26724.
@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

PLAT-240

@dylanhuff-at-coder
dylanhuff-at-coder marked this pull request as ready for review July 23, 2026 23:07
@dylanhuff-at-coder

Copy link
Copy Markdown
Contributor Author

Agents generated, but I reviewed it and it looks good

@geokat geokat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants