Fixing a URL bug in Brave

So this week I was working on the Brave browser issue that was filed by our professor.

The issue was based on retrieving a file path from the URL input from the user. In order to replicate the error a user has to create a file path in their local machine and try to access it using the browser URL.

So I had a file named dogcat.txt located in my desktop that just contained the phrase "hello" in it.

So if you try this is chrome you get the content of the file on the browser.
The file displayed on chrome
As you can see the URL contains the path of the file name does not need to be URL space encoded. (dog%20cat.txt)

But if you try to enter the same file path on the brave URL you get a message saying the path doesn't exist.


Now looking at the source code I saw that most of the url based code was contained in a  'urlutil.js' file that exists in 'js/lib'  subdirectory.


Now there are many ways to make this issue work so I went with a very basic approach , that is to make the file path URL encoded.

So basically I took the file path the user passed as a string and replace whitespace with a '%20'.





This way the file path was shown by the browser.

To add a test I wrote a module in the 'urlutilTest.js' file that tests for URL encoding in file names.



Here is a sample of the results.

Comments

Popular posts from this blog

First Open Source Contribution - debugger.html

Fixing issues in debugger.html.

Utilizing the Leaflet mini map library in a map application.