I’m having an issue and wanted to see if anyone he...
# cfml-general
j
I’m having an issue and wanted to see if anyone here knows of a solution. I have a # in file name that is passed via query string. I tried to replace the #, I tried using encodeforurl, rereplace and other things, but no matter what I try ColdFusion cuts off everything after the #. There’s gotta be a solution for this. Anyone have it?
r
I doubt that CF is doing it. It's an anchor tag to the browser and not really part of the query string.
j
So what’s the work around?
r
It has to be URL encoded.
j
from the get go? But what about now that it’s already there?
r
Yes, when it's passed in.
w
replace the # when it's passed and replace it on the server side? ?filename=``OCTOTHORPE``restoffile.txt and then replace it with #?
or encrypt and decrypt the filename but that seems like overkill
j
Well, at this juncture, the file name is there, so i’m trying to figure out a way now to read it. But I agree, prior to saving and loading, I will have to encode it from this point forward.
r
So,
somn#file
needs to be
some%23file
when passed as a query string.
w
you could just change to a POST instead if that's possible
rodney you sure that will prevent it from being treated as # ? doesn't cf automatically try to urldecode strings?
j
@Rodney And @websolete I appreciate your insights. But what I need for the particular moment is to figure out how to manage the file names now that they are already in with the # symbol.
r
Yes, but I don't think it's getting to CF. The browser usually discards everything from the point of the anchor on.
w
justin, can you change the method to POST ?
☝️ 1
r
In where with the symbol? Your file system?
j
yes
it read the url on the page and then i have code to open the file that is passed in the query string from the file system
w
so it's scraping the url from a page?
j
So for example, the user passes a file name via the URL in the query string and ColdFusion reads the query string and then goes to the file system and grabs the file for the user and then downloads it. But some users saved files with hashtags and so i have to figure out a way for coldfusion to ignore that and treat it as a character. I can easily do this with commas, but you’re right. the browser is treating this as an anchor
The only other option is to change all of the places where the user clicks to download a file and urlencode those places.
i may just have to do that
w
you'll only be able to reliably grab stuff after the hash via javascript afaik. you could write a function to fire onclick and manipulate it however you choose
r
You'll probably need a JavaScript solution to workaround this. It's not really a CF issue given your use case. Unless, they can pass it in using a form with a POST instead of as a URL query string.
j
yeah i agree with you both
i’ll look at that angle and when i have a solution i’ll come back and post it here
w
regardless of the outcome, i'm just happy i was able to use the word octothorpe in a meaningful way
🙄 3
j
hahaha
w
for those that don't know, # is an octothorpe
j
i assume that means 8 pointed object?
w
The More You Know ©
d
And here I thought it was an 8-sided thorpe,
✔️ 1
m
I run into that sometimes when using CSS Colors, often this works ###FFFFFF