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

util: ignore invalid format specifiers #13674

Closed
wants to merge 2 commits into from
Closed

Conversation

targos
Copy link
Member

@targos targos commented Jun 14, 2017

In util.format, if a percent sign without a known type is encountered,
just print it instead of silently ignoring it and the next character.

Fixes: #13665

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

util

In util.format, if a percent sign without a known type is encountered,
just print it instead of silently ignoring it and the next character.

Fixes: nodejs#13665
@nodejs-github-bot nodejs-github-bot added the util Issues and PRs related to the built-in util module. label Jun 14, 2017
// Invalid format specifiers
assert.strictEqual(util.format('a% b', 'x'), 'a% b x');
assert.strictEqual(util.format('percent: %d%, fraction: %d', 10, 0.1),
'percent: 10%, fraction: 0.1');
Copy link
Member

@TimothyGu TimothyGu Jun 14, 2017

Choose a reason for hiding this comment

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

Maybe also test a % at the end of a string?

@joyeecheung
Copy link
Member

@benjamingr
Copy link
Member

+1 on actual changes. Why did you change your mind from the initial suggestion of throwing?

@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 14, 2017
@jasnell
Copy link
Member

jasnell commented Jun 14, 2017

Defensively marking this as a semver-major. While this change is definitely the right thing to do, the change in behavior could potentially break code written to depend on the old behavior (as unlikely as that may be)

@targos
Copy link
Member Author

targos commented Jun 14, 2017

This is actually restoring the old behavior (that was lost in #12407) so I would consider this semver-patch.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@joyeecheung
Copy link
Member

+1 to semver-patch since the old behavior only changed in 8.x

@jasnell
Copy link
Member

jasnell commented Jun 15, 2017

If there are no objections to landing as semver-patch then I'm good with that

@jasnell
Copy link
Member

jasnell commented Jun 15, 2017

/cc @nodejs/ctc ... we have several CTC signoffs already, just want to make sure there are no objections to landing this as a patch.

@jasnell
Copy link
Member

jasnell commented Jun 16, 2017

Landing...

@jasnell jasnell removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 16, 2017
jasnell pushed a commit that referenced this pull request Jun 16, 2017
In util.format, if a percent sign without a known type is encountered,
just print it instead of silently ignoring it and the next character.

PR-URL: #13674
Fixes: #13665
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@jasnell
Copy link
Member

jasnell commented Jun 16, 2017

Landed in 00aac57

@jasnell jasnell closed this Jun 16, 2017
@targos targos deleted the fix-13665 branch June 16, 2017 17:33
addaleax pushed a commit that referenced this pull request Jun 17, 2017
In util.format, if a percent sign without a known type is encountered,
just print it instead of silently ignoring it and the next character.

PR-URL: #13674
Fixes: #13665
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@addaleax addaleax mentioned this pull request Jun 17, 2017
addaleax pushed a commit that referenced this pull request Jun 21, 2017
In util.format, if a percent sign without a known type is encountered,
just print it instead of silently ignoring it and the next character.

PR-URL: #13674
Fixes: #13665
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@addaleax addaleax mentioned this pull request Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants