On Tuesday 20 November 2007 19:15, nextgens at freenetproject.org wrote:
> +    private void migrateOldBookmarks(String[] newVals) {
> +        //FIXME: for some reason that doesn't work... if someone wants to 
fix it ;)
> +        Pattern pattern = Pattern.compile("/(.*/)([^/]*)=(|=)*([A-Z]
{3}@.*).*");

It doesn't work because the optional |= can be happily added to the first part 
of the regex. So the optional bit is never present. You need to get rid of 
it, and manually check for =| at the end of group(2). I wrote code to do this 
which was released in the last build.

> +        FreenetURI key;
> +        clear();
> +        for (int i = 0; i < newVals.length; i++) {
> +            try {
> +                Matcher matcher = pattern.matcher(newVals[i]);
> +                if (matcher.matches() && matcher.groupCount() == 4) {
> +                    makeParents(matcher.group(1));
> +                    key = new FreenetURI(matcher.group(4));
> +                    String title = matcher.group(2);
> +                    boolean hasAnActiveLink = matcher.group(3).indexOf('|') 
> -1;
> +                    addBookmark(matcher.group(1), new BookmarkItem(key,
> +                            title, hasAnActiveLink, node.alerts), false);
> +                }
> +            } catch (MalformedURLException e) {}
> +        }
> +    }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20071120/bbfda726/attachment.pgp>

Reply via email to