Skip to content

fix(images): add indentContinuation ledger and sanitize inline fields (closes #552) - #554

Open
xsvm wants to merge 1 commit into
civitai:mainfrom
xsvm:fix/indent-continuation-call-site-ledger
Open

fix(images): add indentContinuation ledger and sanitize inline fields (closes #552)#554
xsvm wants to merge 1 commit into
civitai:mainfrom
xsvm:fix/indent-continuation-call-site-ledger

Conversation

@xsvm

@xsvm xsvm commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Closes #552.

Summary

Establishes a bidirectional AST call-site ledger for indentContinuation, replaces safeTerm with safeTermSingle across 8 inline positions in images.go to prevent newline row forgery, and expands the #393 anti-corruption harness to guard safeTermSingle.

Key Changes

Area Changes
Sanitizer Added safeTermSingle (strings.ReplaceAll(safeTerm(s), "\n", " ")) in internal/cmd/safeterm.go.
Inline Fields Applied safeTermSingle to 8 fields (Model, Sampler, CfgScale, Steps, Seed, URL, Username, NSFWLevel, and resources[].type/name/weight/hash) in internal/cmd/images.go.
AST & Behaviour Added internal/cmd/indentcontinuation_ledger_test.go with TestIndentContinuationCallSitesAreLedgered (StructuralLedger pins 6 sites; BehaviouralSeam asserts zero \n leaks across all 8 fields + resources).
#393 Hardening Extended internal/cmd/safeterm_userinput_test.go to audit both safeTerm and safeTermSingle (152 calls across 67 files verified).
Docs Documented prompt indent vs wrap rationale in README.md.

Verification

# Closing gate
go test -count=1 ./internal/cmd -run Ledger
# PASS: TestIndentContinuationCallSitesAreLedgered (0.03s)
# PASS: 13 ledger tests (0.622s, exit code 0)

# #393 User-input guard (152 call sites audited)
go test -v -count=1 ./internal/cmd -run TestSafeTermIsNeverAppliedToUserTypedInput
# PASS: TestSafeTermIsNeverAppliedToUserTypedInput (0.03s)

# Regression & Lint
go test -v -count=1 ./internal/cmd -run TestREADMEAnchorLinksResolve
go test -v ./internal/cmd -run TestImages
gofmt -s -l . && go vet ./internal/cmd

…closes civitai#552)

- Introduce safeTermSingle to sanitize inline metadata fields against newline injection

- Replace safeTerm with safeTermSingle for 8 forgeable single-line positions in images.go

- Add bidirectional AST call-site ledger and behavioural seam test in indentcontinuation_ledger_test.go

- Extend civitai#393 anti-corruption test to audit safeTermSingle alongside safeTerm

- Clarify prompt line continuation vs soft wrap behavior in README.md
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.

indentContinuation has no call-site ledger, so 8 forgeable fields in images.go were invisible to the suite (#545 follow-up)

1 participant