带撇号的ColdFusion服务器文件 [英] ColdFusion server file with apostrophe character

查看:71
本文介绍了带撇号的ColdFusion服务器文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试用撇号上传文件时,出现错误:

When I try to upload a file with apostrophe, I get the error:

    Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

如果文件名为test.spdf,则会出现错误。但是,如果我将名称更改为test.pdf,就没有错误。

if the file name is test's.pdf, I get the error. But if I change the name to test.pdf, there is no error.

有人知道为什么吗?

谢谢

推荐答案

我遇到了类似的情况,即我为从查询结果创建excel文件的页面动态创建文件名。我采取的方法是创建一个函数,以某种东西替换所有不良字符。这是该函数的一部分。

I had a similar situation where I was dynamically creating filenames for pages that created excel files from query results. The approach I took was to create a function that replaced all the bad characters with something. Here is part of that function.

<cfargument name="replacementString" required="no" default=" ">
<cfscript>
var inValidFileNameCharacters = "[/\\*'?[\]:><""|]";
return reReplace (arguments.fileNameIn, inValidFileNameCharacters, arguments.replacementString, "all");
</cfscript>

您可能想考虑相反的方法。而不是声明无效字符并替换它们,而是声明有效的字符并替换不在有效字符列表中的任何内容。

You might want to consider an opposite approach. Instead of declaring invalid characters and replacing them, declare valid ones and replace anything that is not in the list of valid characters.

我建议将此函数设置为所有函数都可用适当的页面。如何操作取决于您的情况。

I suggest making this a function that's available on all appropriate pages. How you do that depends on your situation.

这篇关于带撇号的ColdFusion服务器文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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