[gmime] Added IPv6 sample urls to GMimeFilterHTML tests



commit 3be11251acdd7dc2748a42a9cf17d31203e2606c
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Sun Dec 17 16:36:47 2017 -0500

    Added IPv6 sample urls to GMimeFilterHTML tests

 tests/data/filters/html-input.txt              |    8 ++++++++
 tests/data/filters/html-output.blockquote.html |    8 ++++++++
 tests/data/filters/html-output.cite.html       |    8 ++++++++
 tests/data/filters/html-output.mark.html       |    8 ++++++++
 util/url-scanner.c                             |   15 +++++++++++++++
 5 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/tests/data/filters/html-input.txt b/tests/data/filters/html-input.txt
index ceabae6..32cf221 100644
--- a/tests/data/filters/html-input.txt
+++ b/tests/data/filters/html-input.txt
@@ -16,6 +16,14 @@ GMime's URL scanner should also work more complex urls:
 - web url w/ username: http://user domain com/index.html
 - web url w/ user & pass: http://user:pass domain com:80/index.html
 - web url w/ user and domain literal: http://user@[127.0.0.1]/index.html
+- web url w/ IPv6 domain literals:
+  - http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
+  - http://[1080:0:0:0:8:800:200C:417A]/index.html
+  - http://[3ffe:2a00:100:7031::1]
+  - http://[1080::8:800:200C:417A]/foo
+  - http://[::192.9.5.5]/ipng
+  - http://[::FFFF:129.144.52.38]:80/index.html
+  - http://[2010:836B:4179::836B:4179]
 - web url surrounded by []'s: [http://www.google.com/]
 - web url surrounded by ()'s: (http://www.google.com/)
 - web url surrounded by {}'s: {http://www.google.com/}
diff --git a/tests/data/filters/html-output.blockquote.html b/tests/data/filters/html-output.blockquote.html
index 17ebc55..b83c9d6 100644
--- a/tests/data/filters/html-output.blockquote.html
+++ b/tests/data/filters/html-output.blockquote.html
@@ -16,6 +16,14 @@ GMime's URL scanner should also work more complex urls:<br>
 - web url w/ username: <a href="http://user domain com/index.html">http://user domain com/index.html</a><br>
 - web url w/ user &amp; pass: <a href="http://user:pass domain com:80/index.html">http://user:pass domain 
com:80/index.html</a><br>
 - web url w/ user and domain literal: <a 
href="http://user@[127.0.0.1]/index.html";>http://user@[127.0.0.1]/index.html</a><br>
+- web url w/ IPv6 domain literals:<br>
+&nbsp; - <a 
href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html";>http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a><br>
+&nbsp; - <a 
href="http://[1080:0:0:0:8:800:200C:417A]/index.html";>http://[1080:0:0:0:8:800:200C:417A]/index.html</a><br>
+&nbsp; - <a href="http://[3ffe:2a00:100:7031::1";>http://[3ffe:2a00:100:7031::1</a>]<br>
+&nbsp; - <a href="http://[1080::8:800:200C:417A]/foo";>http://[1080::8:800:200C:417A]/foo</a><br>
+&nbsp; - <a href="http://[::192.9.5.5]/ipng";>http://[::192.9.5.5]/ipng</a><br>
+&nbsp; - <a 
href="http://[::FFFF:129.144.52.38]:80/index.html";>http://[::FFFF:129.144.52.38]:80/index.html</a><br>
+&nbsp; - <a href="http://[2010:836B:4179::836B:4179";>http://[2010:836B:4179::836B:4179</a>]<br>
 - web url surrounded by []'s: [<a href="http://www.google.com/";>http://www.google.com/</a>]<br>
 - web url surrounded by ()'s: (<a href="http://www.google.com/";>http://www.google.com/</a>)<br>
 - web url surrounded by {}'s: {<a href="http://www.google.com/";>http://www.google.com/</a>}<br>
diff --git a/tests/data/filters/html-output.cite.html b/tests/data/filters/html-output.cite.html
index a94d9fb..9d4f8ba 100644
--- a/tests/data/filters/html-output.cite.html
+++ b/tests/data/filters/html-output.cite.html
@@ -16,6 +16,14 @@
 &gt; - web url w/ username: <a href="http://user domain com/index.html">http://user domain 
com/index.html</a><br>
 &gt; - web url w/ user &amp; pass: <a href="http://user:pass domain com:80/index.html">http://user:pass 
domain com:80/index.html</a><br>
 &gt; - web url w/ user and domain literal: <a 
href="http://user@[127.0.0.1]/index.html";>http://user@[127.0.0.1]/index.html</a><br>
+&gt; - web url w/ IPv6 domain literals:<br>
+&gt; &nbsp; - <a 
href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html";>http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a><br>
+&gt; &nbsp; - <a 
href="http://[1080:0:0:0:8:800:200C:417A]/index.html";>http://[1080:0:0:0:8:800:200C:417A]/index.html</a><br>
+&gt; &nbsp; - <a href="http://[3ffe:2a00:100:7031::1";>http://[3ffe:2a00:100:7031::1</a>]<br>
+&gt; &nbsp; - <a href="http://[1080::8:800:200C:417A]/foo";>http://[1080::8:800:200C:417A]/foo</a><br>
+&gt; &nbsp; - <a href="http://[::192.9.5.5]/ipng";>http://[::192.9.5.5]/ipng</a><br>
+&gt; &nbsp; - <a 
href="http://[::FFFF:129.144.52.38]:80/index.html";>http://[::FFFF:129.144.52.38]:80/index.html</a><br>
+&gt; &nbsp; - <a href="http://[2010:836B:4179::836B:4179";>http://[2010:836B:4179::836B:4179</a>]<br>
 &gt; - web url surrounded by []'s: [<a href="http://www.google.com/";>http://www.google.com/</a>]<br>
 &gt; - web url surrounded by ()'s: (<a href="http://www.google.com/";>http://www.google.com/</a>)<br>
 &gt; - web url surrounded by {}'s: {<a href="http://www.google.com/";>http://www.google.com/</a>}<br>
diff --git a/tests/data/filters/html-output.mark.html b/tests/data/filters/html-output.mark.html
index 66ebf47..deceb43 100644
--- a/tests/data/filters/html-output.mark.html
+++ b/tests/data/filters/html-output.mark.html
@@ -16,6 +16,14 @@ GMime's URL scanner should also work more complex urls:<br>
 - web url w/ username: <a href="http://user domain com/index.html">http://user domain com/index.html</a><br>
 - web url w/ user &amp; pass: <a href="http://user:pass domain com:80/index.html">http://user:pass domain 
com:80/index.html</a><br>
 - web url w/ user and domain literal: <a 
href="http://user@[127.0.0.1]/index.html";>http://user@[127.0.0.1]/index.html</a><br>
+- web url w/ IPv6 domain literals:<br>
+&nbsp; - <a 
href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html";>http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a><br>
+&nbsp; - <a 
href="http://[1080:0:0:0:8:800:200C:417A]/index.html";>http://[1080:0:0:0:8:800:200C:417A]/index.html</a><br>
+&nbsp; - <a href="http://[3ffe:2a00:100:7031::1";>http://[3ffe:2a00:100:7031::1</a>]<br>
+&nbsp; - <a href="http://[1080::8:800:200C:417A]/foo";>http://[1080::8:800:200C:417A]/foo</a><br>
+&nbsp; - <a href="http://[::192.9.5.5]/ipng";>http://[::192.9.5.5]/ipng</a><br>
+&nbsp; - <a 
href="http://[::FFFF:129.144.52.38]:80/index.html";>http://[::FFFF:129.144.52.38]:80/index.html</a><br>
+&nbsp; - <a href="http://[2010:836B:4179::836B:4179";>http://[2010:836B:4179::836B:4179</a>]<br>
 - web url surrounded by []'s: [<a href="http://www.google.com/";>http://www.google.com/</a>]<br>
 - web url surrounded by ()'s: (<a href="http://www.google.com/";>http://www.google.com/</a>)<br>
 - web url surrounded by {}'s: {<a href="http://www.google.com/";>http://www.google.com/</a>}<br>
diff --git a/util/url-scanner.c b/util/url-scanner.c
index 4a56c7c..6b619d6 100644
--- a/util/url-scanner.c
+++ b/util/url-scanner.c
@@ -373,6 +373,10 @@ url_web_end (const char *in, const char *pos, const char *inend, urlmatch_t *mat
                        /* could be IPv4 or IPv6 */
                        if ((val = strtol (inptr, &end, 10)) < 0)
                                return FALSE;
+                       if ((*end >= 'A' && *end <= 'F') || (*end >= 'a' && *end <= 'f')) {
+                               if ((val = strtol (inptr, &end, 16)) < 0)
+                                       return FALSE;
+                       }
                } else if ((*inptr >= 'A' && *inptr <= 'F') || (*inptr >= 'a' && *inptr <= 'f')) {
                        /* IPv6 address literals are in hex */
                        if ((val = strtol (inptr, &end, 16)) < 0 || *end != ':')
@@ -419,6 +423,17 @@ url_web_end (const char *in, const char *pos, const char *inend, urlmatch_t *mat
                                }
                        } while (end > inptr && *end == ':');
                        
+                       if (*end == '.') {
+                               n = 1;
+                               
+                               do {
+                                       inptr = end + 1;
+                                       if ((val = strtol (inptr, &end, 10)) < 0 || val > 255)
+                                               return FALSE;
+                                       n++;
+                               } while (n < 4 && end > inptr && *end == '.');
+                       }
+                       
                        if (*end != ']')
                                return FALSE;
                        


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]