Skip to content

Conversation

@targos
Copy link
Member

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-botnodejs-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

@TimothyGuTimothyGuJun 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?

@jasnelljasnell 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

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
MemberAuthor

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

Copy link
Member

@mcollinamcollina 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

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

@jasnell
Copy link
Member

/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

Landing...

@jasnelljasnell 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: #13674Fixes: #13665 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
@jasnell
Copy link
Member

Landed in 00aac57

@jasnelljasnell closed this Jun 16, 2017
@targostargos 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: #13674Fixes: #13665 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
@addaleaxaddaleax 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: #13674Fixes: #13665 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
@addaleaxaddaleax mentioned this pull request Jun 21, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

utilIssues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@targos@joyeecheung@benjamingr@jasnell@mcollina@danbev@TimothyGu@cjihrig@nodejs-github-bot