Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Positive numbers with plus sign not quoted correctly with ALWAYS_QUOTE_NUMBERS_AS_STRINGS #373

Closed
dyadyaJora opened this issue Jan 16, 2023 · 3 comments
Labels
2.15 Fix or feature targeted at 2.15 release yaml Issue related to YAML format backend
Milestone

Comments

@dyadyaJora
Copy link

dyadyaJora commented Jan 16, 2023

Hello!
I found a case which is very similar to #182 but for positive numbers with plus sign.
Serializing 14 currently results in "14".
Serializing -14 currently results in "-14".
But Serializing +14 currently results in +14, instead of "+14".

It looks like update PLAIN_NUMBER_P regexp with (-|\\+)?[0-9]*(\\.[0-9]*)? in https://github.com/FasterXML/jackson-dataformats-text/blob/2.15/yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java#L220 should solve this problem.
https://regex101.com/r/eQo6ag/1

Do you have any objections about this fix?
I am ready to open PR =)

@yawkat
Copy link
Member

yawkat commented Jan 17, 2023

im not sure this is a good idea. numbers can get much more complicated than that pattern (octal, exponent, ...), so i'm not sure why a preceding + should be allowed but more complicated patterns should not be.

@cowtowncoder
Copy link
Member

While I agree there may be complications wrt more complex numbers, I do think that addressing this particular issue still makes sense. So I'd be +1 for a patch -- if so, against 2.15 as its still behavioral change that could cause some (bogus test?) failures somewhere and it's better to keep those to minor versions.

@cowtowncoder cowtowncoder added yaml Issue related to YAML format backend 2.15 Fix or feature targeted at 2.15 release labels Jan 17, 2023
@cowtowncoder cowtowncoder changed the title Positive numbers with plus sign not quoted correctly with ALWAYS_QUOTE_NUMBERS_AS_STRINGS Positive numbers with plus sign not quoted correctly with ALWAYS_QUOTE_NUMBERS_AS_STRINGS Feb 10, 2023
@cowtowncoder cowtowncoder added this to the 2.15.0 milestone Feb 10, 2023
@cowtowncoder
Copy link
Member

Implemented as suggested; only adds support for leading +, no further changes for octals etc (not against those but solving one issue at a time, lowest hanging fruit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.15 Fix or feature targeted at 2.15 release yaml Issue related to YAML format backend
Projects
None yet
Development

No branches or pull requests

3 participants