1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed SMF Importer doesn't process BB Code for quotes

Discussion in 'Resolved Bug Reports' started by jeffwidman, Dec 15, 2014.

  1. jeffwidman

    jeffwidman Active Member

    I understand and agree that most BB Code cleanup should be handled by the admin and not the importer, but saw this and thought it'd be relatively easy to add...

    Here's a post in my forum right now (data anonymized). The BB code is just straight text, and didn't transfer as a quote:
    [quote author=Jeff link=topic=8576.msg32075#msg32075 date=13144659]
    Moddy - does this mean various things?
    I can fix this easily enough using the find and replace tool--but only because I preserved content IDs. If I'd merged in content, it'd be a bit trickier as I'd have to have retained the import log to correctly map the IDs.

    Seems like the ideal time to parse this is in the importer itself.
  2. Chris D

    Chris D XenForo Developer Staff Member

    We do actually handle that in the importer.


    The above link shows the regex we use in the importer against the example you provided above, and the eventual substitution.

    We only transfer over the username, though, the rest of the data in the quote is ignored.
  3. Chris D

    Chris D XenForo Developer Staff Member

    The exception may be if the name contains a special character, e.g. Jeff will work but Jeff! won't. In that case the regex may be slightly too strict.
  4. Chris D

    Chris D XenForo Developer Staff Member

    I've fixed this for the next version of the importer, the regex has changed to:

    $string preg_replace('#\[quote\sauthor=(.+)\slink=[^\]]+]#siU''[quote="$1"]'$string);
    That regex may help you with the content replacement tool.
  5. jeffwidman

    jeffwidman Active Member

    Gotcha. That explains why it transferred most quotes, but not all. The actual username includes multiple spaces, an underscore, and a parenthesis.

    Example: "Funky Chicken (aka John_S) "

    Thanks for the updated regex.
  6. Great!

    Latest version can be download from the other thread with smf.php?
  7. Brogan

    Brogan XenForo Moderator Staff Member

    No, it's not currently available.

    You can manually edit the file to the updated regex posted by Chris though.
    Chris D likes this.
  8. jeffwidman

    jeffwidman Active Member

    The post content find/replace plugin kept timing out on me because there were 280,000+ posts that needed updating.

    MariaDB 10 added a regex find-and-replace function, so I just used that:
    UPDATE sj_forum.xf_post SET message = regexp_replace(message, "\\[quote\\sauthor=(.+)\\slink=[^\\]]+]", "\\[quote=\"\\1\"\\]") WHERE message LIKE '%quote author%'
  9. Sorry for this noob question.. where is that find/replace plugin?

Share This Page