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] Ignore comments when decoding XML#26445

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

Closed

Conversation

@q0rban
Copy link

@q0rbanq0rban commentedMar 7, 2018
edited by nicolas-grekas
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsN/A
LicenseMIT
Doc PRN/A

Previously, if the first line of XML was a comment, that would be used as the root node of the decoded XML. This work strips comments from decoded XML by default, but also allows for customizing which XML node types are ignored during decoding. The first two commits in this PR contain tests only to prove the existence of this "bug".

m4olivei reacted with thumbs up emoji
James Sansbury added4 commitsMarch 7, 2018 09:13
Previously, if the first line of XML was a comment, that would be used asthe root node of the decoded XML. This work strips comments from decodedXML by default, but also allows for customizing which XML node types areignored during decoding.
Copy link
Contributor

@ostroluckyostrolucky left a comment

Choose a reason for hiding this comment

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

i like this

* @param int[] $ignoredNodeTypes an array of ignored XML node types, each one of the DOM Predefined XML_* Constants
*/
publicfunction__construct(string$rootNodeName ='response',int$loadOptions =null)
publicfunction__construct(string$rootNodeName ='response',int$loadOptions =null,array$ignoredNodeTypes =null)
Copy link
Contributor

Choose a reason for hiding this comment

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

, array$ignoredNodeTypes =array(XML_PI_NODE,XML_COMMENT_NODE)

then you can get rid of ternary

Copy link
Author

Choose a reason for hiding this comment

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

I wondered about that. I was following the pattern I saw for$loadOptions, but I'm happy to switch to that.

@q0rbanq0rbanforce-pushed theq0rban/XmlEncoder-ignore-comments branch fromdec179a toc6b294cCompareMarch 7, 2018 15:11
@q0rbanq0rbanforce-pushed theq0rban/XmlEncoder-ignore-comments branch fromc6b294c tob55454eCompareMarch 7, 2018 15:13
@q0rban
Copy link
Author

I realized I forgot to update the CHANGELOG.md with some changes I made to the function, so I've updated that now.

* @param int[] $ignoredNodeTypes an array of ignored XML node types, each one of the DOM Predefined XML_* Constants
*/
publicfunction__construct(string$rootNodeName ='response',int$loadOptions =null)
publicfunction__construct(string$rootNodeName ='response',int$loadOptions =null,array$ignoredNodeTypes =array(XML_PI_NODE,XML_COMMENT_NODE))

Choose a reason for hiding this comment

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

the default should be BC -safe, thusXML_COMMENT_NODE should not be listed, isn't it?

Copy link
Contributor

@ostroluckyostroluckyMar 14, 2018
edited
Loading

Choose a reason for hiding this comment

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

Listing XML_COMMENT_NODE is for fixing a bug tho. I don't think anybody relies on old behaviour.

Copy link
Author

Choose a reason for hiding this comment

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

I had originally put BC breaks to yes, but it looks like that was changed at some point. Personally, I think comments should be stripped by default, as a comment at the top of the XML to decode ends up becoming the XML root node. See the tests for an example.

Choose a reason for hiding this comment

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

ok, can you add an entry in the UPGRADE file when, please?

Copy link
Author

Choose a reason for hiding this comment

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

@nicolas-grekas since this is in the 4.1 milestone, I assume you are referring to the UPGRADE-4.1.md file? If so, I pushed a commit to note the change in this PR.

Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

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

minor comment

* added optional`bool $escapeFormulas = false` argument to`CsvEncoder::__construct`
* added`AbstractObjectNormalizer::setMaxDepthHandler` to set a handler to call when the configured
maximum depth is reached
* added optional`int[] $ignoredNodeTypes` argument to`XmlEncoder::__construct`. Xml decoding now
Copy link
Member

Choose a reason for hiding this comment

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

XML

q0rban reacted with thumbs up emoji
@fabpot
Copy link
Member

Thank you@q0rban.

@q0rbanq0rban deleted the q0rban/XmlEncoder-ignore-comments branchMarch 22, 2018 16:44
@fabpotfabpot mentioned this pull requestMay 7, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+2 more reviewers

@ostroluckyostroluckyostrolucky approved these changes

@20uf20uf20uf approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

6 participants

@q0rban@fabpot@nicolas-grekas@ostrolucky@20uf@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp