Re: [PHP] parsing text for special characters



On 11/29/07, Adam Williams <awilliam@xxxxxxxxxxxxxxxx> wrote:
I've got an html form, and I have PHP parse the message variables for
special characters so when I concatenate all off the message variables
together, if a person has put in a ' " or other special character, it
won't break it when it used in mail($to, "MMH Suggestion", "$message",
"$headers"); below is my snippet of code, but is there a better way to
parse the text for special characters. what about if I were to have the
$message inserted into a mysql field? how would I need to handle
special characters that way?

htmlentities()
htmlspecialchars()

first i would run $message = filter_input(INPUT_POST, 'message',
FILTER_SANITIZE_STRING);

then probably $message = htmlspecialchars($message);

that should suffice. it depends i suppose. if you need to dump the
html as-is, or you want to encode it first. i don't trust anything
users submit though, so i encode it on output
.



Relevant Pages

  • Re: Mail and Encoding
    ... Sinan Unur wrote: ... can pull the email using Net::POP3. ... like Outlook forward message where the signature is in HTML some special characters are encode like =20. ... I have tried Encode:: module but I dont know from which table to what ...
    (comp.lang.perl.misc)
  • Re: Mail and Encoding
    ... I am parsing each email using a ... like Outlook forward message where the signature is in HTML some ... special characters are encode like =20. ... I have tried Encode:: module but I dont know from which table to what ...
    (comp.lang.perl.misc)
  • parsing text for special characters
    ... I've got an html form, and I have PHP parse the message variables for special characters so when I concatenate all off the message variables together, if a person has put in a ' " or other special character, it won't break it when it used in mail; below is my snippet of code, but is there a better way to parse the text for special characters. ...
    (php.general)
  • Mail and Encoding
    ... I am trying to parse every email I am getting in a spam@xxxxxxxxxxx I can pull the email using Net::POP3. ... I am parsing each email using a Mail::Internet object. ... The problem I am getting is that in certain case, like Outlook forward message where the signature is in HTML some special characters are encode like =20. ... I have tried Encode:: module but I dont know from which table to what I should convert. ...
    (comp.lang.perl.misc)
  • Re: [PHP] parsing text for special characters
    ... special characters so when I concatenate all off the message variables ... parse the text for special characters. ... in which the string is going to be used. ...
    (php.general)