Skip to:
Content
Pages
Categories
Search
Top
Bottom

Apostrophe and or quotation marks cause backslash to appear.

  • Hello. I notice on my fresh and clean installation that when I use “quotation marks” or when I use an apostrophe in contractions (can’t, shouldn’t, etc.), a backslash appears.

    “quotation marks” –> “quotation marks”

    can’t –> can’t

    I don’t know what’s causing this.

    I have my own dedicated server, so I’m in complete control of everything.

Viewing 22 replies - 1 through 22 (of 22 total)

  • chrishajer
    Participant

    @chrishajer

    What version are you using, is it integrated with WordPress and are you using a language file?

    I think I may be having the same problem. It’s making it very hard to post links in the forum without them breaking. It also seems to be stripping out the http at the beginning of the link, and ” gets converted to ‘ whenever I edit a post. In fact, the only way I can get an a href link to show up correctly is to put quotes of any kind, single or double, around the URL. I’m using 1.01, not sure if I have a language file. Here’s the forum in question: http://forum.blitzentrapper.net


    chrishajer
    Participant

    @chrishajer

    Thanks for the info. Since your site is in English, it’s probably not using another language file. You’d have set it so you would know. It does appear to be integrated with WordPress? If so, what version WordPress and what do you do for integration?

    I’m having this exact problem.

    Fresh install of 1.0.2, integrated with WordPress (finally!), and even though I deactivated all plugins and tested it again, and it’s still doing it.

    Any ideas?

    Never mind – I got it, thanks to an old post from two years ago.

    The code has changed a bit, so here’s how I fixed it:

    1) open up /bb-includes/functions.bb-template.php

    2) replace line 1074 with:

    return stripslashes(apply_filters( ‘get_topic_title’, $topic->topic_title, $id ));

    3) and line 1782:

    return stripslashes(apply_filters( ‘get_post_text’, $bb_post->post_text, $bb_post->post_id ));

    That did the trick for me.

    Is this secure?


    nickaster
    Member

    @nickaster

    Howdy – I don’t have an editor that shows lines – what is the text on the line I should replace?

    Will this screw up future upgrades?


    nickaster
    Member

    @nickaster

    HI adam – thanks for the possible cure. I made the changes you suggested (finally got proper line editor) and I’m still getting those slashes…. check it out – http://www.triplepundit.com/forum

    Any ideas?


    yangers101
    Member

    @yangers101

    I get the same problem.


    yangers101
    Member

    @yangers101

    actually, adamkayce’s fix worked for me! thanks!


    TimBurden
    Member

    @timburden

    adam’s fix will mean backslashes will be stored in the database. Worse, on upgrade, his changes will be lost and there all the backslashes will be.

    Better to do this as a plugin, and filtering content before it goes in the db.

    Just write a plugin, upload it and activate it. Like this:

    <?php
    /*
    Plugin Name: Strip Slashes
    */
    add_filter('pre_topic_title', 'stripslashes', 40);
    add_filter('pre_post', 'stripslashes', 40);
    add_filter('bb_add_topic_tags', 'stripslashes', 40);
    ?>

    Is there a way to fix this issue inside a theme?

    The ‘add_filter’ route only seems to remove slashes from the front-end, but they still show up in the admin.

    Anybody know of a ‘complete’ fix without editing the core?

    ok, found the answer wooooooo!

    The ‘real’ reason this wasn’t working was….

    ‘magic_quotes_gpc’ is set to ‘off’ on my server (in php.ini)

    All these other solutions are band-aids, my hunch is that making sure magic quotes is ‘on’ is the solution.


    jackey
    Participant

    @jackey

    For now this fixes things indeed, however a warning from PHP.net:

    “/This feature has been /DEPRECATED/ as of PHP 5.3.0 and /REMOVED/ as of PHP 6.0.0. Relying on this feature is highly discouraged./”

    Putting “php_value magic_quotes_gpc 1″ in my .htaccess file worked for me… for now.

    Also added: “error_reporting( E_ALL & ~E_DEPRECATED );” to my bb-config.php


    nickaster
    Member

    @nickaster

    YES!!! Adding this to the .htaccess file does indeed work:

    php_value magic_quotes_gpc 1

    I’m worried that now I’m down a rabbit hole in terms of future upgrades and so on. But what can you do…


    kevinator
    Member

    @kevinator

    I added the line above – php_value magic_quotes_gpc 1 – to .htaccess, but it had no effect at all.

    Next?


    Sam Bauers
    Participant

    @sambauers

    magic_quotes_gpc should be off – always, it’s evil.

    If your installation doesn’t work properly with it off it is either a bug or something else is wrong.


    dainismichel
    Participant

    @dainismichel

    added php_value magic_quotes_gpc 1 – to .htaccess in both WPMU ROOT and BBPRESS ROOT DIRS, no effect…


    dainismichel
    Participant

    @dainismichel

    OK, created a file called stripslashes.php and uploaded it to the bb-plugins directory. Used the code from above, and I do have the magic quotes thing going…I think I may take that out of my htacess files though…if it works now…


    Samara
    Member

    @spadilla

    I can confirm that creating a plugin as mentioned above did in fact fix the problems I was having


    iamanasha
    Member

    @iamanasha

    AdamKayce says: Never mind – I got it, thanks to an old post from two years ago.

    The code has changed a bit, so here’s how I fixed it:

    1) open up /bb-includes/functions.bb-template.php

    2) replace line 1074 with:

    return stripslashes(apply_filters( ‘get_topic_title’, $topic->topic_title, $id ));

    3) and line 1782:

    return stripslashes(apply_filters( ‘get_post_text’, $bb_post->post_text, $bb_post->post_id ));

    That did the trick for me.

    {That worked for me too. It did the trick in the frontside and backoffice.}

    Rather than hacking the core, you should put that code into your theme’s functions.php. That’s what apply_filters and add_filter is for!!!!!!!!!! :)

    Add this to your theme’s functions.php:

    add_filter( 'get_topic_title', 'strip_the_title_slashes', 20, 2);
    function strip_the_title_slashes( $title, $id ) {
    return stripslashes( $title );
    }

    add_filter( 'get_post_text', 'strip_the_text_slashes', 20, 2);
    function strip_the_text_slashes( $text, $id ) {
    return stripslashes( $text );
    }

Viewing 22 replies - 1 through 22 (of 22 total)

You must be logged in to reply to this topic.