使用ColdFusion重定向到UTF-8 URL [英] Redirect to UTF-8 URL with ColdFusion

查看:161
本文介绍了使用ColdFusion重定向到UTF-8 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用URL的文件夹名称中使用UTF-8字符的系统。
导航到这些网址并没有问题,一切都按预期工作 - 除了发送重定向到网站上的其他页面时, 浏览器似乎编码扩展字符。



举个例子,我试图重定向到下面的相对URL:

  /geschäft/käfer/ 

如果我直接在地址栏中访问该网址,则没有问题。
但是,如果我更改位置标题以将浏览器重定向到此URL,则结果为:

  / gesch %E4ft / k%E4fer / 

如果我查看原始页面的响应标题(它是我可以看到这个条目:

 位置:/geschäft/käfer/ 

code>

看起来正确的细节在标题中结束,但浏览器的地址栏显示的编码值为% E4 详述如上。
我试图用各种方法将URL输入到位置标题中,但所有结果都一样。



我在Chrome 37.0上看到这种行为.2062.120米和Firefox 32.0.2。

这是在开发包上运行的Windows 7 Home,带有IIS7.5

编辑:
看起来这个问题可能与ColdFusion直接相关。如果我使用Javascript重定向到网址,这可以工作......但要注意文件必须用BOM保存。
如果我使用 cflocation ,或者如果我使用pagecontext手动插入标题,则无论是否存在BOM,问题都会持续存在。



我也注意到使用 cfinclude 的类似问题,除非保存了调用模板,否则这些扩展字符显示不正确与BOM。

解决方案

我去测试这个,并没有看到相同的结果。但后来我再玩一遍,并尝试使用

 < cfprocessingdirective pageencoding =utf-8/> 

立即,我看到了与您完全相同的问题。将它包含在任何页面中似乎很自然。这非常具有推测性,但当与pageencoding指令配合使用时,CFAS可能会在cflocation标记中进行某种URL编码。

假设你的代码在某处存在,请尝试删除它以进行重定向。如果是这样的话,那么我会报告这是Adobe的一个错误。



仅供参考,我这样做 - 输出编码

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

我得到了

 geschäft/käfer/ 

但是当我这样做 - 用编码重定位

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

它将我重新定位到

  gesch%E4ft / k%E4fer / 

当我这样做时 - - 没有编码的输出

 geschäft/käfer/ 

我得到了

 geschäft/käfer/ 

但是当我这样做 - 重新定位没有编码

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

然后我被重新安置到

 geschäft/käfer/ 


I'm working on a system that uses UTF-8 characters in folder names for URLs. There's been no problem in navigating to these URLs and everything works as expected - except when issuing a redirect to another page on the site; whereupon the browser seems to encode the extended characters.

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

/geschäft/käfer/ 

If I visit that URL directly in the address bar, there's no problem. However if I change the location header to redirect the browser to this URL, it ends up at:

/gesch%E4ft/k%E4fer/

If I look in the response headers for the original page (It's a 301 redirect to the translated content) I can see this entry:

Location:/geschäft/käfer/

It seems the correct details are ending up in the header, but the browser's address bar is showing the encoded value with %E4 detailed above. I have attempted various ways of entering the URL into the location header, but all come out with the same result.

I am seeing this behaviour on Chrome 37.0.2062.120 m and on Firefox 32.0.2.

This is running on a dev box, Windows 7 Home with IIS7.5

EDIT: It seems this issue could be related directly to ColdFusion. If I use Javascript to redirect to the url, this works... with the caveat that the file has to be saved with a BOM. If I use cflocation, or if I use the pagecontext to insert the header manually, the issue persists regardless of whether or not a BOM is present.

I've also noticed a similar problem with using cfinclude in that these extended characters are displayed incorrectly unless the calling template is saved with a BOM.

解决方案

I went to test this and didn't see the same result. But then I played with it a little more and tried using

<cfprocessingdirective pageencoding = "utf-8"/>

Immediately, I was able to see the exact same issue that you did. It seems natural to include it in any page. This is very speculative, but CFAS may be doing some kind of URL encoding in the cflocation tag when used in conjunction with the pageencoding directive.

Assuming you have this in your code somewhere, try removing it for the redirect. If that works, then I would report this as a bug to Adobe.

Just FYI, I did this -- Output with encoding

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

And I got

geschäft/käfer/

But when I did this -- Relocation with encoding

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

It relocated me to

gesch%E4ft/k%E4fer/

And when I did this --Output without encoding

geschäft/käfer/
<cfabort>

I got

geschäft/käfer/

But when I did this -- Relocation without encoding

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

Then I was relocated to

geschäft/käfer/

这篇关于使用ColdFusion重定向到UTF-8 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆