Advertisement:

Author Topic: createPost adds slashes after ' --> \'  (Read 362 times)

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,779
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
createPost adds slashes after ' --> \'
« on: June 18, 2018, 09:28:58 PM »
I'm using createPost in a test SMF 2 website and every time a topic with apostrophes is created, SMF doesn't convert it into an html code, but rather adds slashes '\.

I think in SMF 1 it's change them to '

How can I prevent slashes being added?

Offline TehCraw

  • Jr. Member
  • **
  • Posts: 243
  • Gender: Male
Re: createPost adds slashes after ' --> \'
« Reply #1 on: June 18, 2018, 09:32:03 PM »
Investigation would require installing a 2.x copy, which I'm not feeling right now, so can't give an exact answer as to why. But I'd suggest running your input through htmlspecialchars($input, ENT_QUOTES);

That should fix it.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,779
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: createPost adds slashes after ' --> \'
« Reply #2 on: June 18, 2018, 09:58:49 PM »
Thank you, but it didn't work ... Here's my code

Code: [Select]
$subject = mysql_escape_string( $subject );

$subject = htmlspecialchars( $subject, ENT_QUOTES );

$subject = un_htmlspecialchars($subject);

$subject = strip_tags($subject);

$subject = strtr(htmlspecialchars($subject), array("\r" => '', "\n" => '', "\t" => ''));

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,948
  • Gender: Male
    • Kindred-999 on GitHub
Re: createPost adds slashes after ' --> \'
« Reply #3 on: June 18, 2018, 10:22:20 PM »
Yes, I believe that the slash is correct. That’s how it gets stored 8m the databae, iirc
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Online vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,099
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: createPost adds slashes after ' --> \'
« Reply #4 on: June 18, 2018, 10:41:44 PM »
i would skip  mysql_escape_string as long as you are using the createpost for the subject it should work ok.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,779
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: createPost adds slashes after ' --> \'
« Reply #5 on: June 18, 2018, 10:46:23 PM »
i would skip  mysql_escape_string as long as you are using the createpost for the subject it should work ok.

That did it.

Ty