ASP/VBScripting: Error Using Commas in File NamesRSS

17 replies

Last post Dec 03, 2004 02:14 PM by ChicoUser

  • ASP/VBScripting: Error Using Commas in File Names

    Nov 29, 2004 02:02 PM|sitisdeus|LINK

    I have an ASP application that I'm working on that contains links to documents and allows users to Open/Save read-only copies of the specified documents. There are tons of files that are being accessed and some of the file names contain commas. The ones without commas work fine, but any files with commas do not provide users with the Open/Save popup because it errors out. The link is generated correctly, but is not executed correctly. I am using an HTML table to store the document names, which are pulled from a SQL Server 2000 database. The problem isn't with retrieving the file names from the database as those are generating perfectly fine; they are also linking to the appropriate places. For example, if I have file "Test Document, Revision 3" it appears exactly like that in the database. I'm utilizing vbscript's escape and unescape functions to convert any spaces/non-alphanumeric characters to their designated ASCII values. Here is a sample of how this is working: These are the database values that would be retrieved: INTERNAL NAME: Test Document, Revision 3.doc ORIGINAL NAME: Test Document, Revision 3.doc The HTML td tag appears as follows, where oRsAttachments = recordset of data: &approved=1"> The open_file.asp page is solely responsible for opening the file and provides the Open/Save popup to view/download a read-only copy of the selected document. In this case, the URL generated looks like this: http://blah/open_file.asp?filename=Test%20Document%2C%20Revision%203.doc Are there any known problems with commas that might be setting this off? Like I said, items without commas work just fine; however, I have not checked the usual problem characters in file names either (!"@#$%^&*~,'/ \?). It was my assumption that links containing commas, and any other questionable characters for that matter, would use the ASCII characters and work sufficiently. Please let me know of any possible solutions!! Thanks much! sd
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Nov 29, 2004 10:17 PM|ChicoUser|LINK

    have you tried it without escaping the name? An alternative could be to use the Server.UrlEncode and Server.UrlDecode methods.
    Nobler sentiments, stronger minds
    -
    Francisco
    (A+,MCP,.NET Framework Certified)
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Nov 30, 2004 09:06 AM|tomkmvp|LINK

    Are you running URLScan? Do really need to have comma's in the names? It's really better to stick to alphanumerics for filenames on the web ...
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 01, 2004 12:10 PM|sitisdeus|LINK

    I have tried doing it without escaping the name, and that didn't work either.
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 01, 2004 12:11 PM|sitisdeus|LINK

    Like I said earlier, there are a lot of filenames with commas in them already. If it was up to me, I would just set a standard to go without commas. However, since there are already a lot of documents with commas in them, I am trying to provide a fix so that the filenames work with commas.
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 01, 2004 12:13 PM|sitisdeus|LINK

    What is URLScan? I'm not familiar with that. Could you provide more information on its purpose and/or an example of how that could help me out?
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 01, 2004 04:29 PM|tomkmvp|LINK

    URLScan: http://support.microsoft.com/default.aspx?scid=kb;en-us;307608 How are you handling the filename in your ASPX? Maybe it needs to be unencoded?
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 02, 2004 12:18 PM|ChicoUser|LINK

    Well, the wiki folks are using commas; I wonder how the heck they're doing it? http://en.wikipedia.org/wiki/Hanford,_Washington
    Nobler sentiments, stronger minds
    -
    Francisco
    (A+,MCP,.NET Framework Certified)
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 09:20 AM|sitisdeus|LINK

    The filename is escaped in configuring the tag: e.g. &approved=0">) The filename then uses the unescape method in opening the file. However, I removed the call to unescape the filename and it makes no difference at all. The filenames with commas don't work, and the ones without commas still work. filename = unescape(request("filename")) Any clues???
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 10:35 AM|tomkmvp|LINK

    Looking back through the previous posts, you haven't really made it clear what "errors out" and "don't work" mean. Please be more specific about what happens. What's the exact error message you're getting? Does the IIS log file show anything for the comma files?
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 11:16 AM|sitisdeus|LINK

    When clicking on a document name, such as "Test Doc, rev. 1", a "Page cannot be displayed HTTP 500 - Internal server error" occurs. With ANY names without commas, the Open/Save download dialog box is displayed. I don't have access to the IIS log file as I am a developer, not a network admin. I am confused as to why EVERY other character in the file names work (!"@#$%^&*/~' \?). Why commas don't work, I have no idea. If I just have to make a rule that no commas can be used in the file names, that's what I might have to do. I just wanted to see if anyone came across a comma fix for such a situation.
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 11:26 AM|ChicoUser|LINK

    Did you try? &approved=0">link I have no way of tesing this myself so...let us know.
    Nobler sentiments, stronger minds
    -
    Francisco
    (A+,MCP,.NET Framework Certified)
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 11:34 AM|ChicoUser|LINK

    Nobler sentiments, stronger minds
    -
    Francisco
    (A+,MCP,.NET Framework Certified)
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 12:32 PM|sitisdeus|LINK

    I ran the application with the following code: &approved=0"> and the same error occurred. It seems like the Server.UrlEncode and vbScript's escape do the same thing if I'm getting the same error using both. I'm in the process of trying to check out the IIS log file to see if that will show something I'm missing at this point. Let me know if you have any ideas in the meantime, and I will post back if I find out any new information that I can pass along. Thanks for the suggestion!
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 01:40 PM|tomkmvp|LINK

    Ok - for "Page cannot be displayed HTTP 500 - Internal server error" you'll need to turn off friendly error messages in IE so we can get the detailed message - it's impossible to fix the error without knowing what it is. http://www.aspfaq.com/show.asp?id=2109 http://support.microsoft.com/?id=311766 http://support.microsoft.com/?id=309051
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 01:52 PM|sitisdeus|LINK

    Ok, I turned off the friendly error messages and got the following error when I attempted to open a file name with a comma: \directory\documents\Test Document, rev 2.doc Server.MapPath() error 'ASP 0173 : 80004005' Invalid Path Character /erdb/open_file.asp, line 54 An invalid character was specified in the Path parameter for the MapPath method. This is what is on line 52-54: 52: response.write filename 53: filename=request("filename") 54: strFilename = server.MapPath(filename) Any ideas now how to fix this? Is there some way to check for invalid characters in a MapPath?
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 02:04 PM|sitisdeus|LINK

    FOUND THE FIX: http://fx-scripts.com/codebank.asp Got it working! Thanks to all who helped me in getting to this point!
  • Re: ASP/VBScripting: Error Using Commas in File Names

    Dec 03, 2004 02:14 PM|ChicoUser|LINK

    Ah. Try: 53: filename=Server.UrlDecode(request("filename")) Source: http://www.foxweb.com/document/index.htm?page=/document/ServerObject.htm
    Nobler sentiments, stronger minds
    -
    Francisco
    (A+,MCP,.NET Framework Certified)