[smuxi] Engine(-Tests): implemented IPv4 and IPv6 link detection support
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi] Engine(-Tests): implemented IPv4 and IPv6 link detection support
- Date: Tue, 9 Dec 2014 17:01:18 +0000 (UTC)
commit 505723f3623b855fc3395862448e12875f6df591
Author: Mirco Bauer <meebey meebey net>
Date: Tue Dec 9 17:59:52 2014 +0100
Engine(-Tests): implemented IPv4 and IPv6 link detection support
src/Engine-Tests/MessageBuilderTests.cs | 33 +++++++++++++++++++++++++++
src/Engine/Config/MessageBuilderSettings.cs | 13 +++++++---
2 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/src/Engine-Tests/MessageBuilderTests.cs b/src/Engine-Tests/MessageBuilderTests.cs
index 8c9fbdf..9d481e9 100644
--- a/src/Engine-Tests/MessageBuilderTests.cs
+++ b/src/Engine-Tests/MessageBuilderTests.cs
@@ -609,5 +609,38 @@ namespace Smuxi.Engine
builder.Append(new UrlMessagePartModel("mailto:larry google com", "larry google com"));
TestMessage(msg, builder.ToMessage());
}
+
+ [Test]
+ public void AppendIPv4Links()
+ {
+ var builder = new MessageBuilder();
+ builder.TimeStamp = DateTime.MinValue;
+ builder.Append(new UrlMessagePartModel("http://127.0.0.1"));
+ TestMessage("http://127.0.0.1", builder.ToMessage());
+
+ builder = new MessageBuilder();
+ builder.TimeStamp = DateTime.MinValue;
+ builder.Append(new UrlMessagePartModel("http://93.220.211.43:40000"));
+ TestMessage("http://93.220.211.43:40000", builder.ToMessage());
+ }
+
+ [Test]
+ public void AppendIPv6Links()
+ {
+ var builder = new MessageBuilder();
+ builder.TimeStamp = DateTime.MinValue;
+ builder.Append(new UrlMessagePartModel("http://[::1]"));
+ TestMessage("http://[::1]", builder.ToMessage());
+
+ builder = new MessageBuilder();
+ builder.TimeStamp = DateTime.MinValue;
+ builder.Append(new UrlMessagePartModel("http://[2003:71:ce67:e700:3631:c4ff:fe2b:f874]:40000/"));
+ TestMessage("http://[2003:71:ce67:e700:3631:c4ff:fe2b:f874]:40000/", builder.ToMessage());
+
+ builder = new MessageBuilder();
+ builder.TimeStamp = DateTime.MinValue;
+ builder.Append(new UrlMessagePartModel("http://[2a01:4f8:a0:7041::2]/"));
+ TestMessage("http://[2a01:4f8:a0:7041::2]/", builder.ToMessage());
+ }
}
}
diff --git a/src/Engine/Config/MessageBuilderSettings.cs b/src/Engine/Config/MessageBuilderSettings.cs
index 3e65bdd..18ac096 100644
--- a/src/Engine/Config/MessageBuilderSettings.cs
+++ b/src/Engine/Config/MessageBuilderSettings.cs
@@ -75,16 +75,21 @@ namespace Smuxi.Engine
string subdomain = domainchars + @"\.";
string common_tld = @"de|es|im|us|com|net|org|info|biz|gov|name|edu|onion|museum";
string any_tld = @"[a-z]+";
+ string ip6 = @"(?:[0-9a-f]{0,4}:){1,7}[0-9a-f]{1,4}";
+ string quoted_ip6 = @"\[" + ip6 + @"\]";
+ string ip4 = @"(?:[0-9]{1,3}\.){3}[0-9]{1,3}";
+ string ip = "(?:" + ip4 + "|" + ip6 + "|" + quoted_ip6 + ")";
string domain = @"(?:(?:" + subdomain + ")+(?:" + any_tld + ")|localhost)";
+ string host = "(?:" + domain + "|" + ip + ")";
string short_number = "[1-9][0-9]{,4}";
string port = ":" + short_number;
string user = "[a-z0-9._%+-]+@";
- string domain_port = domain + "(?:" + port + ")?";
+ string host_port = host + "(?:" + port + ")?";
+ string user_host_port = "(?:" + user + ")?" + host_port;
string user_domain = user + domain;
- string user_domain_port = "(?:" + user + ")?" + domain_port;
string path = @"/(?:["+ path_chars +"]*["+ path_last_chars +"]+)?";
string protocol = @"[a-z][a-z0-9\-+]*://";
- string protocol_user_domain_port_path = protocol + user_domain_port + "(?:" + path + ")?";
+ string protocol_user_host_port_path = protocol + user_host_port + "(?:" + path + ")?";
// facebook attachment
var regex = new Regex(
@@ -98,7 +103,7 @@ namespace Smuxi.Engine
// protocol://user domain:port/path
regex = new Regex(
- protocol_user_domain_port_path,
+ protocol_user_host_port_path,
RegexOptions.IgnoreCase | RegexOptions.Compiled
);
BuiltinPatterns.Add(new MessagePatternModel(regex));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]