From: David ‘Bombe’ Roden Date: Wed, 8 Jun 2011 10:53:08 +0000 (+0200) Subject: Allow null contexts. X-Git-Tag: 0.6.5^2~9^2~4 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=94f4a128230d29346545a764d3b4ce984f78fbbc;p=Sone.git Allow null contexts. --- 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. */