Single and Double quotes are escaped with a backslash

Single and Double quotes are escaped with a backslash

broder22broder22 Posts: 5Questions: 2Answers: 1

Fields with single or double quotes have a backslash appended before the quote, the number of backslashes seem to double each time the field is saved.

I have tried disabling xss on the field, which hasnt helped.
Field::inst( 'orders.taxnotes' )->xss( false ),

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @broder22 ,

    I just tried this - I'm assuming you're using Editor - and it behaved as expected.

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • broder22broder22 Posts: 5Questions: 2Answers: 1

    Thanks for the response! Sorry I didn't include one right away. I stripped it down to the most basic html/php/js and it still seems to behave this way. If I had to guess I'd say its related to the JSON responses, as this is how it escapes quotes.

    https://fitzpatrickselect.com/beta/test.html

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @broder22 ,

    It might also be a PHP issue - these two SO threads here and here may help, they show how to prevent it on that end. Could you give that a try too please, just to confirm either way,

    Cheers,

    Colin

  • broder22broder22 Posts: 5Questions: 2Answers: 1

    Seems like that was the problem, thanks for your help! I guess it was just an odd default setting by the web host.

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin

    It sounds like "magic quotes" was enabled on the server, or something like that. It was a hacky way to try and prevent SQL injection in old PHP scripts. Thankfully, that option is gone in modern PHP, but I guess it lives on in legacy!

    Allan

This discussion has been closed.