changeset 27877:d8d514121c71

added is_zenkaku_space() so that url can be separated from trailing multi byte string as well.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 05 Sep 2008 13:34:15 +0000
parents 5c76f76ee9db
children 9205382c2711
files libpurple/util.c
diffstat 1 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/util.c	Fri Sep 05 10:01:57 2008 +0000
+++ b/libpurple/util.c	Fri Sep 05 13:34:15 2008 +0000
@@ -2006,6 +2006,20 @@
 }
 
 static gboolean
+is_zenkaku_space(const char *c)
+{
+    gboolean rv = FALSE;
+    const guchar *u = (guchar *)c;
+
+    if(!c || !strcmp(c, "") || strlen(c) < 3)
+        rv = FALSE;
+    else if(*u == 0xe3 && *(u+1) == 0x80 && *(u+2) == 0x80)
+        rv = TRUE;
+
+    return rv;
+}
+
+static gboolean
 badchar(char c)
 {
 	switch (c) {
@@ -2086,7 +2100,7 @@
 					(!g_ascii_strncasecmp(c, "https://", 8)))) {
 			t = c;
 			while (1) {
-				if (badchar(*t) || badentity(t)) {
+				if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) {
 
 					if ((!g_ascii_strncasecmp(c, "http://", 7) && (t - c == 7)) ||
 						(!g_ascii_strncasecmp(c, "https://", 8) && (t - c == 8))) {
@@ -2120,7 +2134,7 @@
 			if (c[4] != '.') {
 				t = c;
 				while (1) {
-					if (badchar(*t) || badentity(t)) {
+					if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) {
 						if (t - c == 4) {
 							break;
 						}
@@ -2151,7 +2165,7 @@
 		} else if (!g_ascii_strncasecmp(c, "ftp://", 6) || !g_ascii_strncasecmp(c, "sftp://", 7)) {
 			t = c;
 			while (1) {
-				if (badchar(*t) || badentity(t)) {
+				if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) {
 
 					if ((!g_ascii_strncasecmp(c, "ftp://", 6) && (t - c == 6)) ||
 						(!g_ascii_strncasecmp(c, "sftp://", 7) && (t - c == 7))) {
@@ -2181,7 +2195,7 @@
 			if (c[4] != '.') {
 				t = c;
 				while (1) {
-					if (badchar(*t) || badentity(t)) {
+					if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) {
 						if (t - c == 4) {
 							break;
 						}
@@ -2208,7 +2222,7 @@
 		} else if (!g_ascii_strncasecmp(c, "mailto:", 7)) {
 			t = c;
 			while (1) {
-				if (badchar(*t) || badentity(t)) {
+				if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) {
 					char *d;
 					if (t - c == 7) {
 						break;
@@ -2242,7 +2256,7 @@
 				   (c == text || badchar(c[-1]) || badentity(c-1))) {
 			t = c;
 			while (1) {
-				if (badchar(*t) || badentity(t)) {
+				if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) {
 
 					if (t - c == 5) {
 						break;