Solved

File names with & character

Posted on 2016-08-09
6
88 Views
Last Modified: 2016-08-16
I am creating pdf files on a web server; the file name is based on a company name; some companies have the & character in the name, for example, SMITH&JONES.

Will this create an issue by attaching a pdf file with the name like SMITH&JONES.pdf to an email to send to someone? Emails created using phpMailer with attachment on web server.

Can abobe acrobat reader or other 3rd party pdf readers accept file names containing an &?

Thanks
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 250 total points
ID: 41749079
Assuming everybody escapes the "&" character properly, yes it should work fine.

The ampersand character is not a reserved character for most filesystems, meaning you can put it into filenames in Windows without any trouble and Adobe Reader and other programs will open it no problem.

It IS, however, a special character in URLs, because it denotes the end of one HTTP GET parameter and the start of the next parameter in a URL, e.g. "http://mywebsite.com/somepage.php?param1=foo¶m2=bar".

So if any website (including your own webserver) ever references the file name in the URL, it would need to make sure it is escaped properly, e.g. "http://mywebsite.com/somepage.php?file=SMITH&JONES".

You might also need to properly escape the character if you execute a bash script that references the filename, e.g. "mv /var/lib/foo/SMITH\&JONES.pdf  /foo/bar"

So assuming that the various technologies that you use escape and sanitize user input properly, you should have no problems.
0
 

Author Comment

by:Richard Korts
ID: 41749106
Frosty555,

I am aware of the "Get" consideration; that's what made me think this could be an issue to begin with. Use of & in urls is as you said.

So I think the only remaining question is if I build an email and attach a file named SMITH&JONES.pdf, will that go OK as far as email is concerned?

Thanks,

Richard
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 41749147
Here's my take on it, purely philosophical based on experience and without any instant testing to back it up.

File names are for the computers; they should never matter to the humans at all.  In fact, it is usually best to have a separate "display name" for the humans that is aligned with the true file name through some kind of translation table.

If you do it this way, you can display SMITH&JONES and keep the true (computer) file name out of the (human) display.  This means that you can use only known good values for the file names, avoiding the use of special characters, blanks, URL-sensitive characters, etc.

TL;DR: Use only A-Z, 0-9, and underscore in file names.  You will never have a problem with those characters.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Richard Korts
ID: 41749245
Ray,

That's what I kind of thought.

Just hoping to avoid some programming mods.

Thanks
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41749400
No, just fix it.  Get the '&' out of the file names and URLs.  Even & in a URL gets interpreted as '&'.
0
 

Author Comment

by:Richard Korts
ID: 41749444
Yes, Dave.

I'm going to do that.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question