commit:b6235374b91ba7acf62c06c72de2f1291f46ac4c
author:Chip Black
committer:Chip Black
date:Mon Jan 17 03:31:51 2011 -0600
parents:86333bedb512d2fd809c3161bc40e682b2e9938b
Restrict usernames to the same character set as tags
diff --git a/database/database.h b/database/database.h
line changes: +3/-0
index 4c5853e..2f71bee
--- a/database/database.h
+++ b/database/database.h
@@ -7,6 +7,9 @@
 #include <stdint.h>
 #include <time.h>
 
+#define VALID_CHAR(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_')
+#define WHITESPACE(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r')
+
 struct record {
 	uint32_t offset;
 	uint16_t length;

diff --git a/database/tags.c b/database/tags.c
line changes: +2/-3
index a28df02..51d8698
--- a/database/tags.c
+++ b/database/tags.c
@@ -12,10 +12,9 @@
 #include <sys/mman.h>
 #include "tags.h"
 #include "util.h"
+#include "database.h"
 #include "config.h"
 
-#define TAG_CHAR(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_')
-#define WHITESPACE(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r')
 
 int tag_scan(const char *author, const char *data, int len, uint64_t record) {
 	char *taglist[MAX_TAGS_PER_RECORD];
@@ -32,7 +31,7 @@ tag_scan_start:
 			}
 			int begin = i;
 			int start = ++i;
-			while (i < len && TAG_CHAR(data[i]) && (i - start < MAX_TAG_LENGTH)) {
+			while (i < len && VALID_CHAR(data[i]) && (i - start < MAX_TAG_LENGTH)) {
 				i++;
 			}
 			if (start - i == 0) continue;

diff --git a/database/util.c b/database/util.c
line changes: +1/-1
index 2accd5d..6a37e49
--- a/database/util.c
+++ b/database/util.c
@@ -2,7 +2,7 @@
  * BSD-style license.  Please see the COPYING file for details.
  */
 
-#define VALID_CHAR(x) (x == ' ' || x == '\'' || x == '-' || x == '.' || (x >= '0' && x <= '9') || (x >= 'A' && x <= 'Z') || x == '_' || (x >= 'a' && x <= 'z'))
+#include "database.h"
 
 int valid_name(const char *name) {
 	int i;