aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_uri.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-21 12:54:44 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-21 12:54:44 +0000
commit59d63f89e82ccf724ac7c95f2e589d75a4eb0cc8 (patch)
treeb2de864167c12f9f2f165b9827b06e3a3006efe0 /src/fs/fs_uri.c
parentfef75e2cf4dbd36a09d7f853f91a7a7f2542d34b (diff)
downloadgnunet-59d63f89e82ccf724ac7c95f2e589d75a4eb0cc8.tar.gz
gnunet-59d63f89e82ccf724ac7c95f2e589d75a4eb0cc8.zip
fix #1784
Diffstat (limited to 'src/fs/fs_uri.c')
-rw-r--r--src/fs/fs_uri.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index eedf72e04..2057a18f6 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -1033,6 +1033,9 @@ canonicalize_keyword (const char *in)
1033 wpos++; 1033 wpos++;
1034 break; 1034 break;
1035 default: 1035 default:
1036 if (isspace ((unsigned char) *rpos) ||
1037 isdigit ((unsigned char) *rpos) )
1038 break;
1036 /* replace characters listed above with '_' */ 1039 /* replace characters listed above with '_' */
1037 *wpos = '_'; 1040 *wpos = '_';
1038 wpos++; 1041 wpos++;
@@ -1059,16 +1062,38 @@ GNUNET_FS_uri_ksk_canonicalize (const struct GNUNET_FS_Uri *uri)
1059 struct GNUNET_FS_Uri *ret; 1062 struct GNUNET_FS_Uri *ret;
1060 unsigned int kc; 1063 unsigned int kc;
1061 unsigned int i; 1064 unsigned int i;
1062 char **kl; 1065 const char *in;
1066 char *sb;
1067 char *cc;
1068 const char *tok;
1063 1069
1064 kc = uri->data.ksk.keywordCount;
1065 kl = GNUNET_malloc (kc * sizeof (char *));
1066 for (i = 0; i < kc; i++)
1067 kl[i] = canonicalize_keyword (uri->data.ksk.keywords[i]);
1068 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); 1070 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
1069 ret->type = ksk; 1071 ret->type = ksk;
1070 ret->data.ksk.keywordCount = kc; 1072 kc = uri->data.ksk.keywordCount;
1071 ret->data.ksk.keywords = kl; 1073 for (i = 0; i < kc; i++)
1074 {
1075 in = uri->data.ksk.keywords[i];
1076 GNUNET_FS_uri_ksk_add_keyword (ret,
1077 &in[1],
1078 (in[0] == '+') ? GNUNET_YES : GNUNET_NO);
1079 sb = GNUNET_strdup (&in[1]);
1080#define DELIMS " \\|\"'`/&@-_,.;!?+-*^$#~=[]{}()<>"
1081 for (tok = strtok (sb, DELIMS); NULL != tok; tok = strtok (NULL, DELIMS))
1082#undef DELIMS
1083 {
1084 if (strlen(tok) < 3)
1085 continue;
1086 GNUNET_FS_uri_ksk_add_keyword (ret,
1087 tok,
1088 GNUNET_NO);
1089 cc = canonicalize_keyword (tok);
1090 if (strlen (cc) > 2)
1091 GNUNET_FS_uri_ksk_add_keyword (ret,
1092 cc,
1093 GNUNET_NO);
1094 }
1095 GNUNET_free (sb);
1096 }
1072 return ret; 1097 return ret;
1073} 1098}
1074 1099