• I think this plugin is really usefull. But when I tried to import the bookmarks, it was returning an empty array from the netscape bookmark parser.

    If you want make it work, change line 85 from this

    $lines = explode("\n", $this->sanitizeString($bookmarkString));

    to this
    //$lines = explode("\n", $this->sanitizeString($bookmarkString));
    $lines = preg_split('/\r\n|\r|\n/', $bookmarkString);

    on vendor/netscape-bookmark-parser/NetscapeBookmarkParser.php

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jan Boddez

    (@janboddez)

    Interesting! I was assuming the parser to “just work” but I guess I was wrong. Assuming the EOL character depends on the OS (and browser) the bookmarks file was generated with, too. (That is, I don’t think this behavior is related to the WP version.)

    Let’s see if we can hard-fork the parser library and fix this for real.

    Thread Starter Francisco GP (crishnakh)

    (@crishnakh)

    Great. My comment about the wordpress version is because the plugin shows “This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.” ??

    Plugin Author Jan Boddez

    (@janboddez)

    Yep, I didn’t explicitly test this plugin for a while (but I’ve no reason to suspect it no longer works) …

    I’m wondering if instead of the proposed change, the following code change would work for you as well (line 281 of the same file):

    
    //$sanitized = \str_replace("\r", '', $sanitized);
    $sanitized = \preg_replace('~\R~u', "\n", $sanitized);
    

    Seems (if it works) just a tad cleaner that way.

    Also, kind of curious what browser/OS combination outputs (I’m assuming) \r EOL characters rather than \n or \r\n

    Thread Starter Francisco GP (crishnakh)

    (@crishnakh)

    Hi! I tried first with EOL but it doesn’t work. My browser was chrome and I save the file exported on macos last version.

    Did you test my code? I’ll try to test your version, I’ll write back to you.

    Plugin Author Jan Boddez

    (@janboddez)

    I did not test it yet. I mean, I trust it works, but it also skips sanitizing altogether!

    Do you happen to have a bookmarks file you would want to share, for testing purposes? I’d like to investigate a bit more. Feel free to email me at jan AT janboddez DOT be.

    The original code just strips \r, which would leave \n intact and convert \r\n to \n, so I can only assume there are other linebreak characters out there. The snippet I posted should convert all of them to \n, yet leave the other sanitization functions untouched.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘You can make it work with last version of wordpress (5.6.2)’ is closed to new replies.