Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] Add CDATA_WRAPPING_NAME_PATTERN support to XmlEncoder#60355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Deltachaos wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromDeltachaos:feature/cdata-names

Conversation

Deltachaos
Copy link
Contributor

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
Issues
LicenseMIT

AddCDATA_WRAPPING_NAME_PATTERN support to XmlEncoder

This PR introduces a new option for the Symfony Serializer component'sXmlEncoder:CDATA_WRAPPING_NAME_PATTERN.

While Symfony already providesCDATA_WRAPPING_PATTERN to wrap fieldcontent in CDATA based on a regex match, this new feature enables CDATA wrapping based on thefield name—regardless of the field's content.

Example use case:

$this->encoder->encode($data,'xml', [    XmlEncoder::CDATA_WRAPPING_NAME_PATTERN =>'(firstname|lastname)']);

This ensures that fields namedfirstname orlastname are always wrapped in CDATA tags, even if their content doesn't match the typical pattern used byCDATA_WRAPPING_PATTERN.

Motivation:

  • Consistent Output: In many integration scenarios (e.g., with legacy systems, XML consumers, or strict XSD schemas), consumers expect certain fields toalways use CDATA sections—even when their content doesn't require escaping. This option allows for deterministic XML output by name.

  • Better Control: It separates concerns: one can now configure CDATA-wrapping forcontent-based needs andfield-based policies independently.

  • Backward Compatible: The feature is fully optional and does not interfere with existing behavior unless the option is explicitly set.

@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

3 participants
@Deltachaos@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp