Problem with " being replaced with \"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trackbikes
    New Member
    • Jul 2006
    • 1

    #1

    Problem with " being replaced with \"

    I am having a problem with a script that is having content posted to it (articles)
    Any where in the content where there is a " or a ' this gets replaced with \' or \"

    This renders all urls completly useless.

    a sample is below

    There\'s a common misconception that adware just displays advertisements, and so -- although a nuisance -- is harmless. Unfortunately, the opposite is true and \'harmless\' adware is far outweighed by what I term \'surreptitious \' adware --

    and

    <a href=\"http://www.avlplastics urgery.com/\">

    anyone know what could be causing this and a cure?
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    the script is adding \ to replace ' and " to stop sql injections which can be a real problem. so what you need to is replace the string with "" where \ is
    basicly when your inserting data into a database from a variable you want todo this because say your string looks like this
    variable = ' or 1 = 1
    strsql = "select * from users where user_name='vari able'"
    it now becomes "select * from users where user_name = '' or 1=1"
    which can cause some problems... so basicly your problem is its trying to encode the post to make it harder for a sql injection.

    Comment

    • iam_clint
      Recognized Expert Top Contributor
      • Jul 2006
      • 1207

      #3
      BTW i believe its called character escaping if i am not mistaking

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Originally posted by iam_clint
        BTW i believe its called character escaping if i am not mistaking
        Completely correct and it is present in a lot of languages and communications protocols, special characters (normally the delimiters for a string or message) have to be escaped to appear in the middle of a string (or message), then of course in order to get the escape character itself that also has to be escaped.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          But I really don't see the problem. It is a standard precaution to add slashes and when you want to get rid of them with, e.g. posted data, you just do
          [PHP]$var = stripslashes($_ POST['name']) [/PHP]

          Ronald :cool:

          Comment

          Working...