[empathy: 1/2] String parser is changed in order not to break URLs at apostrophes.
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 1/2] String parser is changed in order not to break URLs at apostrophes.
- Date: Tue, 2 Nov 2010 09:05:40 +0000 (UTC)
commit 6f6c118815634fa3ddbd62df46e7447341a81f5b
Author: Vitaly Minko <vitaly minko gmail com>
Date: Mon Nov 1 18:55:00 2010 +0300
String parser is changed in order not to break URLs at apostrophes.
libempathy-gtk/empathy-string-parser.c | 12 ++++++------
tests/empathy-parser-test.c | 6 +++++-
2 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/libempathy-gtk/empathy-string-parser.c b/libempathy-gtk/empathy-string-parser.c
index 45ae6a7..3bb6a82 100644
--- a/libempathy-gtk/empathy-string-parser.c
+++ b/libempathy-gtk/empathy-string-parser.c
@@ -27,14 +27,14 @@
#include "empathy-ui-utils.h"
#define SCHEMES "([a-zA-Z\\+]+)"
-#define INVALID_CHARS "\\s\"'"
-#define INVALID_CHARS_EXT INVALID_CHARS "\\[\\]<>(){},;:?"
-#define BODY "([^"INVALID_CHARS"]+)"
-#define BODY_END "([^"INVALID_CHARS"]*)[^"INVALID_CHARS_EXT".]"
-#define BODY_STRICT "([^"INVALID_CHARS_EXT"]+)"
+#define INVALID_CHARS "\\s\"<>"
+#define INVALID_CHARS_EXT INVALID_CHARS "\\[\\](){},;:"
+#define INVALID_CHARS_FULL INVALID_CHARS_EXT "?'"
+#define BODY "([^"INVALID_CHARS_FULL"])([^"INVALID_CHARS_EXT"]*)"
+#define BODY_END "([^"INVALID_CHARS"]*)[^"INVALID_CHARS_FULL".]"
#define URI_REGEX "("SCHEMES"://"BODY_END")" \
"|((www|ftp)\\."BODY_END")" \
- "|((mailto:)?"BODY_STRICT"@"BODY"\\."BODY_END")"
+ "|((mailto:)?"BODY"@"BODY"\\."BODY_END")"
static GRegex *
uri_regex_dup_singleton (void)
diff --git a/tests/empathy-parser-test.c b/tests/empathy-parser-test.c
index 5713d96..a79a7a2 100644
--- a/tests/empathy-parser-test.c
+++ b/tests/empathy-parser-test.c
@@ -44,6 +44,8 @@ test_parsers (void)
"http://foo.com; bar", "[http://foo.com]; bar",
"http://foo.com: bar", "[http://foo.com]: bar",
"http://foo.com:bar", "[http://foo.com:bar]",
+ "http://apos'foo.com", "[http://apos'foo.com]",
+ "mailto:bar'?user server com", "[mailto:bar'?user server com]",
/* They are not links! */
"http://", "http[:/]/", /* Hm... */
@@ -54,7 +56,7 @@ test_parsers (void)
"mailto:user com", "mailto:user com",
"user com", "user com",
- /* Links inside (), {}, [], <> or "" */
+ /* Links inside (), {}, [], <>, "" or '' */
/* FIXME: How to test if the ending ] is matched or not? */
"Foo (www.foo.com)", "Foo ([www.foo.com])",
"Foo {www.foo.com}", "Foo {[www.foo.com]}",
@@ -68,6 +70,8 @@ test_parsers (void)
"Foo [user server com]", "Foo [[user server com]]",
"Foo <user server com>", "Foo <[user server com]>",
"Foo \"user server com\"", "Foo "[user server com]"",
+ "<a href='http://apos'foo.com'>bar</a>", "<a href='[http://apos'foo.com]'>bar</a>",
+ "Foo 'bar'?user server com'", "Foo '[bar'?user server com]'",
/* Basic smileys */
"a:)b", "a[:)]b",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]