Repository navigation
fix(generator): escape control characters in generated string literals - #164
Merged
Merged
Conversation
leoafarias
force-pushed
the
codex/ack-v2-generator-literals
branch
from
September 29, 2026 14:09
4440287 to
d241b4c
Compare
This was referenced Sep 29, 2026
leoafarias
changed the base branch from
main
to
feat/short-model-schema-accessor
September 29, 2026 14:10
leoafarias
added this pull request to stack #178
September 29, 2026 14:11
leoafarias
force-pushed
the
codex/ack-v2-generator-literals
branch
from
September 29, 2026 14:21
d241b4c to
9d3b2df
Compare
leoafarias
force-pushed
the
feat/short-model-schema-accessor
branch
from
September 29, 2026 14:21
53e8d0f to
15974c5
Compare
leoafarias
force-pushed
the
codex/ack-v2-generator-literals
branch
from
September 29, 2026 14:55
9d3b2df to
f552a36
Compare
leoafarias
force-pushed
the
feat/short-model-schema-accessor
branch
from
September 29, 2026 14:55
15974c5 to
6a1337d
Compare
leoafarias
marked this pull request as ready for review
September 29, 2026 15:08
leoafarias
force-pushed
the
feat/short-model-schema-accessor
branch
from
September 29, 2026 15:43
6a1337d to
dc85ba8
Compare
leoafarias
force-pushed
the
codex/ack-v2-generator-literals
branch
from
September 29, 2026 15:43
f552a36 to
e35891d
Compare
The generator had four copies of its string-literal helper. They escaped quotes, backslashes, and `$` but wrote real newlines into single-quoted Dart source, so a @pattern, discriminator, or key value with a line terminator generated invalid code. Share one dartStringLiteral helper that also writes C0 controls and U+2028/U+2029 as \uXXXX. Rebuilt from #164 (c9adbcd..4440287) on the 1.7 release baseline.
leoafarias
removed this pull request from stack #178
September 29, 2026 16:53
leoafarias
added a commit
that referenced
this pull request
Sep 29, 2026
Align the six publishable packages at 1.7.0-beta.1 and move unreleased notes into the 1.7.0-beta.1 changelog sections. The release includes shared inference, model adapter schemas, CodecSchema.canEncode, typed copyWith, stricter constrained-Set validation, the @AckInfer schema shorthand (#174), generated string-literal escaping (#164), and explicit schema descriptions (#176). Update PUBLISHING.md for this candidate. The Draft 2020-12 runtime (#171), JSON Schema-to-Dart generation (#167), and the decoder error contract (#163) are deferred to 2.0.
leoafarias
force-pushed
the
feat/short-model-schema-accessor
branch
from
September 29, 2026 16:53
dc85ba8 to
edbedc2
Compare
leoafarias
force-pushed
the
codex/ack-v2-generator-literals
branch
from
September 29, 2026 16:53
e35891d to
ab642a9
Compare
Base automatically changed from
feat/short-model-schema-accessor
to
release/1.7
September 29, 2026 16:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The generator had four copies of its string-literal helper (shared inference, schema-first emitter, class-first emitter, class-first graph builder). They escaped quotes, backslashes, and
$, but wrote raw line terminators into single-quoted Dart source. A@Pattern, discriminator, or key value containing a newline or carriage return therefore generated invalid code. Other control characters were legal but unreadable.dartStringLiteralhelper that also writes C0 control characters and U+2028/U+2029 as\uXXXX. DEL (0x7F) is legal in Dart strings and stays raw.string_literal_test.dartround-trips several values through the Dart parser and checks that line terminators are escaped.inference_literal_test.dartexercises the public shared-inference interface with four cases. The LF/CRLF case fails without the fix; the others lock in existing escaping and the new\uXXXXoutput.Scope change
This fix now ships in Ack 1.7. The branch is one commit on the 1.7 stack (base: #174) instead of the older
mainsnapshot, and it covers every generator literal, not only shared inference. The test file uses formatter output, which fixes the earlier CI formatting failure. The changelog entry is in the1.7.0-beta.1section; published history is untouched.It stays independent of #163, which remains 2.0. Unpaired UTF-16 surrogates in annotation values are not handled; that is a possible follow-up.
Validation
Validated locally on the combined 1.7 tree (
feat/ackmodel-class-description, head2d632300), which includes every PR in the stack:dart run melos run test --no-selectpassed. Strict analysis (--fatal-infos) found no issues in all seven packages. Tests passed:ack1,311,ack_generator347,ack_firebase_ai98,ack_mcp_dart63,ack_json_schema_builder51,ack_annotations8, plus the root and example suites.*.ack.dart/*.g.dart, thenmelos run build) reproduced the committed output exactly.dart scripts/api_check.dart 1.6.2reported no breaking changes in any of the six packages. It cannot inspect generated consumer code, so it does not flag the typedcopyWithgetter; theack_generatorchangelog documents that under Breaking.dart scripts/publish_dry_run.dartreported 0 warnings for all six packages.verify_release_tag v1.7.0-beta.1 --skip-ancestry,dart format --set-exit-if-changed, andgit diff --checkpassed.Setcodegen in chore(release): prepare Ack 1.7.0-beta.2 #168,schemaimport prefix in feat(generator): add a static schema shorthand to AckInfer models #174) and the non-blocking fixes are included.