ariya/phantomjs — pull request #304 by jimevans (2012-08-20 14:59:28+00:00)
Title: Fixing Windows-specific path issues with loading of modules

Fixes issue 721 (http://code.google.com/p/phantomjs/issues/detail?id=721).

The dirname() function in bootstrap.js strips everything after the last slash character ('/'). Module.prototype._getPaths() calls dirname() in a loop until all tokens have been processed. The problem is when there is no slash in the final token of the directory, as in the case of a Windows path with a drive designator. _getPaths() eventually calls dirname() with only the drive designator (e.g., 'C:'), which is not empty, which causes _getPaths() to call dirname() again with only the drive designator, resulting in an infinite loop.

Note that a secondary change included as part of this pull request is that joinPath() now uses a slash ('/') instead of a platform-specific separator. While the QT framework will properly normalize path separators, the JavaScript engine requires an already-normalized path.