util: ignore invalid format specifiers#13674
Conversation
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
| // 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'); |
There was a problem hiding this comment.
Maybe also test a % at the end of a string?
|
+1 on actual changes. Why did you change your mind from the initial suggestion of |
|
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) |
|
This is actually restoring the old behavior (that was lost in #12407) so I would consider this semver-patch. |
|
+1 to semver-patch since the old behavior only changed in 8.x |
|
If there are no objections to landing as semver-patch then I'm good with that |
|
/cc @nodejs/ctc ... we have several CTC signoffs already, just want to make sure there are no objections to landing this as a patch. |
|
Landing... |
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>
|
Landed in 00aac57 |
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>
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>
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), orvcbuild test(Windows) passesAffected core subsystem(s)
util