From 9b807c325d514e75835bb778be493e52dfbae3ac Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 5 Dec 2013 04:28:28 +0100 Subject: [PATCH] Add support for bitcoin URIs --- src/com/fsck/k9/helper/HtmlConverter.java | 4 +++- src/com/fsck/k9/helper/Regex.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/helper/HtmlConverter.java b/src/com/fsck/k9/helper/HtmlConverter.java index e17d3ed23..4ad398fc4 100644 --- a/src/com/fsck/k9/helper/HtmlConverter.java +++ b/src/com/fsck/k9/helper/HtmlConverter.java @@ -392,7 +392,9 @@ public class HtmlConverter { * @param outputBuffer Buffer to append linked text to. */ private static void linkifyText(final String text, final StringBuffer outputBuffer) { - Matcher m = Regex.WEB_URL_PATTERN.matcher(text); + String prepared = text.replaceAll(Regex.BITCOIN_URI_PATTERN, "$0"); + + Matcher m = Regex.WEB_URL_PATTERN.matcher(prepared); while (m.find()) { int start = m.start(); if (start == 0 || (start != 0 && text.charAt(start - 1) != '@')) { diff --git a/src/com/fsck/k9/helper/Regex.java b/src/com/fsck/k9/helper/Regex.java index 8eb3765b8..dd60134a0 100644 --- a/src/com/fsck/k9/helper/Regex.java +++ b/src/com/fsck/k9/helper/Regex.java @@ -103,4 +103,7 @@ public class Regex { "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" + ")+" ); + + public static final String BITCOIN_URI_PATTERN = + "bitcoin:[1-9a-km-zA-HJ-NP-Z]{27,34}(\\?[a-zA-Z0-9$\\-_.+!*'(),%:@&=]*)?"; }