Chutzpah Fails When '#' Character in Test File Path


Referenced in HTML test runner:

<script type="text/javascript" src="file:///d:/workspace/dropbox/programming workspace/c#/personal projects/nancyangular/nancyangular/scripts/test.js"></script>

Uncaught SyntaxError: Unexpected token < /D:/workspace/dropbox/programming%20workspace/c/#/personal projects

Moving the file out of the 'C#' directory:

Fixed the issue.

file attachments

Closed Jul 11, 2013 at 5:10 AM by mmanela


mmanela wrote Mar 7, 2013 at 4:53 PM

You should encode # as %23. Try that out and let me know if that works.

MattRetallack wrote May 9, 2013 at 2:24 PM

The same happens if your username contains a hash, or any file path (or temporary file path, including username) contains a non-url compatible unicode character.

The error is caused by line 193 of TestHarness.cs.
Basically change this:
return "file:///" + referencePath.Replace('\\', '/');
to this:
return "file:///" + HttpUtility.UrlEncode(referencePath).Replace("%5C", "/");
I've attached a patched copy of chutzpah.dll that has this fix (built from the commit 162004a847ae version)

MattRetallack wrote May 9, 2013 at 2:44 PM

actually, this would possibly be better (to allow for unicode characters):
return "file:///" + HttpUtility.UrlEncodeUnicode(referencePath).Replace("%5c", "/");

mmanela wrote May 14, 2013 at 5:14 AM

Fixed in changeset 1f6570dd727f