UTF-8 URL Redirection Using ColdFusion

I am working on a system that uses UTF-8 characters in folder names for URLs. There was no problem navigating to these URLs, and everything worked as expected - except when you send a redirect to another page on the site; after which the browser seems to encode extended characters.

To give an example, I'm trying to redirect to the following relative URL:

/geschäft/käfer/ 

If I find this URL directly in the address bar, there is no problem. However, if I change the location header to redirect the browser to this URL, it ends with:

 /gesch%E4ft/k%E4fer/ 

If I look in the response headers to the original page (this is a 301 redirect to the translated content), I can see this entry:

 Location:/geschäft/käfer/ 

It seems that the correct details end in the header, but the encoded value with % E4 , described in detail above, is displayed in the address bar of the browser. I tried to use different ways to enter the URL into the location header, but they all have the same result.

I observe this behavior on Chrome 37.0.2062.120 m and on Firefox 32.0.2.

This works on dev, Windows 7 Home with IIS7.5

EDIT: Looks like this problem could be directly related to ColdFusion. If I use Javascript to redirect to the url, this works ... with the caveat that the file must be saved using the specification. If I use cflocation , or if I use pagecontext to insert the header manually, the problem persists whether the specification is present or not.

I also noticed a similar problem with using cfinclude in that these extended characters are not displayed correctly if the calling pattern is not saved using the spec.

+6
source share
2 answers

I went to check this and did not see the same result. But then I played with him a little more and tried to use

 <cfprocessingdirective pageencoding = "utf-8"/> 

Immediately, I was able to see the same problem as you. It seems natural to include it in any page. This is very speculative, but CFAS can do some kind of URL encoding in the cflocation tag when used in conjunction with the pageencoding directive.

Assuming you have this in your code, try deleting it for redirection. If this works, I report it as an Adobe error.

Just FYI, I did it - Encoding output

 <cfprocessingdirective pageencoding = "utf-8"/> geschäft/käfer/ 

And I got

 geschäft/käfer/ 

But when I did it - Moving with encoding

 <cfprocessingdirective pageencoding = "utf-8"/> <cflocation url="geschäft/käfer/" addtoken="false" /> 

He moved me to

 gesch%E4ft/k%E4fer/ 

And when I did it - Exit without coding

 geschäft/käfer/ <cfabort> 

I got

 geschäft/käfer/ 

But when I did it - Moving without coding

 <cflocation url="geschäft/käfer/" addtoken="false" /> 

Then I was moved to

 geschäft/käfer/ 
+3
source

I tried this, but he could not get it to work. I ended up doing cflocation manually. Like this:

 <cfprocessingdirective pageencoding = "utf-8"/> <cfheader charset="utf-8" name="location" value="geschäft/käfer/"> <cfheader statuscode="302"> 

It worked like a charm for me.

+2
source

Source: https://habr.com/ru/post/975666/


All Articles