Developer forum

Forum » CMS - Standard features » URL encoding plus sign + not working as expected.

URL encoding plus sign + not working as expected.

Charles Johnson
Reply

We have a serial number search on our website to allow users to search for their computer, and download drivers:

https://www.boxx.com/support/technical-support#serial-num

 

In the right hand form, you would type in your serial number, and click submit.  A serial number you can use for testing is: B181374

 

The file structure for the driver files is generated automatically, in the form DriverType/Motherboard/OperatingSystem/FileName.exe

 

This has worked well, with a few exceptions because of special characters.  We caught most of those in our initial implementation, but are running into an issue with operating systems that have a plus “+” symbol in their name.  This is a huge percentage of the files that are already on our website, and a huge percentage of the systems we sell, so changing all of the paths would be extremely difficult.  Here’s an example of a link that is being returned:

https://www.boxx.com/drivers/drivers/Motherboards/30338-ASROCK%20Z390%20TAICHI%20Motherboard/91031-Microsoft%20Windows%2010%20Pro%20Workstation%204C+%20(OA3)/01_Floppy(v16.7.0.1009).exe

 

As you can see, there’s a + sign toward the end of the string.  It makes sense to me that this would return a 404, because the server is treating that as a space, instead of as a + sign.  This is exactly what happens, even though the file is there (see the attached file).

I would think I could URL encode the link in the template, which would result in a link that would look like this (replacing the + with %2B):

https://www.boxx.com/drivers/drivers/Motherboards/30338-ASROCK%20Z390%20TAICHI%20Motherboard/91031-Microsoft%20Windows%2010%20Pro%20Workstation%204C%2B%20(OA3)/01_Floppy(v16.7.0.1009).exe

 

This doesn’t work, for the completely opposite reason, the link doesn’t un-encode the %2B back into a + sign, so that the path would be correct.

 

Any ideas on why this would be happening, or what we could do to resolve it?

 

Thanks in advance!
Charles

FilePathAndFile.JPG

Replies

 
Nicolai Pedersen
Reply

Hi Charles

+ is a reserved URL character, so it has to be handled by URL encoding it as you have figured out. Your link 2 above works well for me. So I think it is a matter of getting the link in the template right. But ensure you do not URL encode already encoded strings - that would make it double encoded.

BR Nicolai

 

You must be logged in to post in the forum