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

html reporter link to specific test is broken on some special characters #1687

Closed
amir-arad opened this issue May 6, 2015 · 4 comments · Fixed by #1698
Closed

html reporter link to specific test is broken on some special characters #1687

amir-arad opened this issue May 6, 2015 · 4 comments · Fixed by #1698
Labels
type: bug a defect, confirmed by a maintainer

Comments

@amir-arad
Copy link

If the test title contains some special characters (for instance $ or () ) then its link in the HTML report does not work.

IMO the fix should be escaping regex here before calling encodeURIComponent(s)

@boneskull boneskull added type: bug a defect, confirmed by a maintainer Unconfirmed status: accepting prs Mocha can use your help with this one! labels May 12, 2015
@benvinegar
Copy link
Contributor

I can reproduce the bug.

Digging deeper, the issue is caused because the grep query string argument is passed verbatim into the RegExp constructor, here:

if (query.grep) mocha.grep(new RegExp(query.grep));

Because the grep argument isn't escaped, it produces regex objects like:

/test that $.jQuery works/

Which of course don't work.

Patch incoming.

@benvinegar
Copy link
Contributor

My bad. I had this backwards. --grep expects an escaped regex string ... so @amir-arad has it correctly.

@kevinbarabash
Copy link

I'm on an 1.21.4 and would like to upgrade. I tried upgrading to the current 2.2.5 and encountered this issue immediately b/c all of our tests have (version 4) to indicate the version of the build system. It makes it hard to investigate individual test failures.

@dasilvacontin
Copy link
Contributor

@KevinB7, could you try @benvinegar's patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants