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

assert: fix EOL issue in messages on Windows #20754

Closed
wants to merge 1 commit into from

Conversation

BridgeAR
Copy link
Member

My take of #19221. @joyeecheung please feel free to close this PR and just update yours.

I cite @joyeecheung:

On Windows if an error is thrown from a script that uses \n
to break lines - which is very common in the JavaScript ecosystem,
and is the case in our own code base -
then the error messages would contain mixed line feeds:
the part coming from the source code breaks with \n while the
message itself break with \r\n.

Since we do not use \r\n in util.inspect(), we should use \n
in error messages as well.
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@BridgeAR BridgeAR requested a review from joyeecheung May 15, 2018 20:04
@nodejs-github-bot nodejs-github-bot added the assert Issues and PRs related to the assert subsystem. label May 15, 2018
@BridgeAR
Copy link
Member Author

.slice(args[0].start, args[args.length - 1].end)
.replace(escapeSequencesRegExp, escapeFn);
if (EOL === '\r\n') {
message = message.replace(/\r\n/g, '\n');
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I am just bikeshedding, but what if the user deliberately put \r\n in their custom messages?

Copy link
Member Author

Choose a reason for hiding this comment

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

This message is not a user message. It is the code that is read and parsed from the file.

Copy link
Member

Choose a reason for hiding this comment

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

@BridgeAR Oh, didn't look at this close enough, sorry. In that case it should probably be fine.

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 16, 2018
BridgeAR added a commit to BridgeAR/node that referenced this pull request May 18, 2018
PR-URL: nodejs#20754
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@BridgeAR
Copy link
Member Author

Landed in 2c42999

@BridgeAR BridgeAR closed this May 18, 2018
MylesBorins pushed a commit that referenced this pull request May 22, 2018
PR-URL: #20754
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@addaleax addaleax mentioned this pull request May 22, 2018
@BridgeAR BridgeAR deleted the fix-assert-eol branch January 20, 2020 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. author ready PRs that have at least one approval, no pending requests for changes, and a CI started.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants