You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Validate voice and prosody options before building SSML - #5
Voice, rate, pitch and volume are now checked before they go into the SSML, so a quote can no longer close the attribute and inject SSML. A bad value throws InvalidOptionError, and both handlers answer 400 for it, and bad host defaults throw when the handler is created. Tests use node:test against the built output, with a new CI step.
No actionable comments were generated in the recent review.
Walkthrough
SSML option values are validated before synthesis. Both handler types validate configured defaults and return HTTP 400 for invalid options. Tests cover rejection, valid SSML construction, text escaping, and handler responses.
Changes: SSML Option Validation
Layer / File(s)
Summary
Validate and build SSML src/server.ts, src/server/edge-tts.ts, test/ssml-injection.test.mjs
The server entry point exports InvalidOptionError, assertOptions, and buildSsml. buildSsml validates voice and prosody values, escapes text, and constructs SSML. EdgeTTS.synthesize builds SSML before WebSocket setup. Tests cover invalid attributes and valid SSML construction.
Validate handler defaults and requests src/server/handler.ts, test/ssml-injection.test.mjs, README.md, package.json, .github/workflows/ci.yml
Both handler factories validate configured defaults. Fetch and Express/Connect handlers return status 400 for InvalidOptionError. Tests cover handler responses and defaults. The README lists invalid options as 400-response conditions, and the package and CI workflows run the tests.
The change validates voice, rate, pitch and volume before building SSML, and both handlers return 400 for invalid options. This closes the injection path described in the linked issue. No concrete merge-blocking risk remains. Symbolic prosody values such as "slow" are now rejected, but the repository does not document them as supported.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "Validate voice and prosody options before building SSML" matches the main change. The PR adds an InvalidOptionError class, validation for voice, rate, pitch, and volume, and handler 400 res…
Linked Issues check
Issue #2 requires that voice, rate, pitch and volume be validated or escaped before SSML construction, so a quote-containing rate never appears raw in an attribute. At the reviewed head, `src/server/e…
Out of Scope Changes check
The whole-PR diff (merge base 78cb3bd to head 9060916) changes these areas: option validation and buildSsml in src/server/edge-tts.ts; 400 mapping and checkDefaults in src/server/handler.ts; r…
Full details: Title check
Explanation
The title "Validate voice and prosody options before building SSML" matches the main change. The PR adds an InvalidOptionError class, validation for voice, rate, pitch, and volume, and handler 400 responses. The changeset validates these options in edge-tts.ts and buildSsml before SSML is built, so the title states the primary change accurately.
Full details: Linked Issues check
Explanation
Issue #2 requires that voice, rate, pitch and volume be validated or escaped before SSML construction, so a quote-containing rate never appears raw in an attribute. At the reviewed head, src/server/edge-tts.ts defines VOICE_RE (^[A-Za-z0-9]+(-[A-Za-z0-9]+)+$) and PROSODY_RE (^(default|[+-]?\d+(\.\d+)?(%|Hz|st)?)$). buildSsml calls checkOption on all four values before it builds the SSML string, and checkOption throws InvalidOptionError on any mismatch. Neither regex admits quotes, angle brackets, or spaces, so the 100%'><break .../> payload from the issue is rejected. EdgeTTS.synthesize calls buildSsml before it opens the WebSocket, so the raw attribute interpolation is gone. The request path in src/server/handler.ts passes body.rate, body.pitch, body.volume and body.voice into synthesize, so the check covers request input. Both handler factories map InvalidOptionError to HTTP 400, which matches the PR description. checkDefaults runs at factory creation, so invalid host defaults fail at setup. The issue's separate timeout request is out of scope and is not required. I did not read test/ssml-injection.test.mjs. The PASS rests on the source code, not on the test coverage.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff (merge base 78cb3bd to head 9060916) changes these areas: option validation and buildSsml in src/server/edge-tts.ts; 400 mapping and checkDefaults in src/server/handler.ts; re-exports in src/server.ts; the new test file; package.json (test script); the CI test step; and a README table row. The validation, handler, and test changes implement issue #2. The src/server.ts re-exports of InvalidOptionError, assertOptions, and buildSsml expose the new validation API. The package.json and CI changes add the node --test run that the tests need. The README row documents the new 400 cases. The reordering of SSML construction ahead of the WebSocket open is a supporting change for the validation. No change is unrelated to issue #2. The issue's timeout suggestion is not implemented, which is correct because it is out of scope.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: f5c11584-355f-49a8-9ce0-ae3fe928ca03
Commits
Reviewing files that changed from the base of the PR and between 78cb3bd and 9060916.
Files selected for processing: 7
.github/workflows/ci.yml
README.md
package.json
src/server.ts
src/server/edge-tts.ts
src/server/handler.ts
test/ssml-injection.test.mjs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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
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.
Voice, rate, pitch and volume are now checked before they go into the SSML, so a quote can no longer close the attribute and inject SSML. A bad value throws
InvalidOptionError, and both handlers answer 400 for it, and bad host defaults throw when the handler is created. Tests usenode:testagainst the built output, with a new CI step.Closes #2
Summary by CodeRabbit
New Features
Tests
Documentation