From 94f4a128230d29346545a764d3b4ce984f78fbbc Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 8 Jun 2011 12:53:08 +0200 Subject: [PATCH] Allow null contexts. --- src/main/java/net/pterodactylus/sone/text/Parser.java | 2 +- src/main/java/net/pterodactylus/sone/text/SoneTextParser.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/text/Parser.java b/src/main/java/net/pterodactylus/sone/text/Parser.java index 9c5a2da..87cdab5 100644 --- a/src/main/java/net/pterodactylus/sone/text/Parser.java +++ b/src/main/java/net/pterodactylus/sone/text/Parser.java @@ -34,7 +34,7 @@ public interface Parser { * Create one or more {@link Part}s from the given text source. * * @param context - * The parser context + * The parser context (may be {@code null}) * @param source * The text source * @return The parsed parts diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index 68a32d0..98bb800 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -242,7 +242,7 @@ public class SoneTextParser implements Parser { if (name == null) { name = link.substring(0, Math.min(9, link.length())); } - boolean fromPostingSone = ((linkType == LinkType.SSK) || (linkType == LinkType.USK)) && (context.getPostingSone() != null) && link.substring(4, Math.min(link.length(), 47)).equals(context.getPostingSone().getId()); + boolean fromPostingSone = ((linkType == LinkType.SSK) || (linkType == LinkType.USK)) && (context != null) && (context.getPostingSone() != null) && link.substring(4, Math.min(link.length(), 47)).equals(context.getPostingSone().getId()); parts.add(new FreenetLinkPart(link, name, fromPostingSone)); } catch (MalformedURLException mue1) { /* not a valid link, insert as plain text. */ -- 2.7.4