Results 1 to 5 of 5

Thread: Does email text need to be escaped?

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default Does email text need to be escaped?

    Assuming a plain text email (not html or anything special), should post data be escaped somehow? And how?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    I guess that if it's not going into a db I don't see the necessity of escaping even though I do it for unknown reasons. The only real thing I make sure of is when the email arrives that it doesn't have slashes in front of quotes and such, just use stripslashes then is what I do.

    You know far more than me on php and I don't know of any way that it would make any difference is it was escaped or not cause it's running any query or anything.

  3. The Following User Says Thank You to fastsol1 For This Useful Post:

    djr33 (10-11-2010)

  4. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    if it's not being used in a database query, output to the browser (where it would be parsed as html), or similar, there's no reason to escape it. Just make sure your email is being send as plain text. If you do escape it, you'll either:

    a) have backslashes in the middle of your sentences
    b) have to use stripslashes(), which basically equates to not escaping anything in the first place.

  5. The Following User Says Thank You to traq For This Useful Post:

    djr33 (10-11-2010)

  6. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Right. This is only for plain text emails that won't be doing anything else later on the server or anything.

    What I'm wondering is if there's some magical way to do code injection in emails that would do something odd in the email program, like in HTML how you could inject Javascript.

    I assume it's unlikely, but in theory there could be some email markup language I'm not aware of. For example, perhaps there's a way to signal an attachment and add some random text (of that file).

    It's probably entirely irrelevant for my current project, but I thought of that today-- it's strange using $_POST data directly without escaping in any way.

    From what you've said, it sounds like you're confirming there's nothing to worry about. Thanks.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Email clients are designed not to do that kind of thing.
    If someone out there is using a client that does, it's not something you can control (or reasonably anticipate).

  8. The Following User Says Thank You to traq For This Useful Post:

    djr33 (10-12-2010)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •