summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2010-12-04 18:35:13 (GMT)
committer Daniel Silverstone <dsilvers@netsurf-browser.org>2010-12-04 18:35:13 (GMT)
commitd1bc31f47387eda79db87e7db958ea5ed50eaee4 (patch)
tree8c00ff3cfdd2e298b237298e095a2fade2e4d372
parent2fee3114b46682b220c73aae7c4f2466dedb81ff (diff)
downloadlibparserutils-d1bc31f47387eda79db87e7db958ea5ed50eaee4.tar.gz
libparserutils-d1bc31f47387eda79db87e7db958ea5ed50eaee4.tar.bz2
Make sure we elide trailing non-characters when matching aliases
svn path=/trunk/libparserutils/; revision=10973
-rw-r--r--src/charset/aliases.c4
-rw-r--r--test/aliases.c8
2 files changed, 12 insertions, 0 deletions
diff --git a/src/charset/aliases.c b/src/charset/aliases.c
index 5c173d0..81962eb 100644
--- a/src/charset/aliases.c
+++ b/src/charset/aliases.c
@@ -62,6 +62,10 @@ static int parserutils_charset_alias_match(const void *a, const void *b)
s_alias++;
}
+ while ((key_left > 0) && IS_PUNCT_OR_SPACE(*s_key)) {
+ key_left--; s_key++;
+ }
+
return key_left - alias_left;
}
diff --git a/test/aliases.c b/test/aliases.c
index 9a9f962..819e4b5 100644
--- a/test/aliases.c
+++ b/test/aliases.c
@@ -28,6 +28,14 @@ int main (int argc, char **argv)
return 1;
}
+ c = parserutils_charset_alias_canonicalise("csinvariant\"", 12);
+ if (c) {
+ printf("%s %d\n", c->name, c->mib_enum);
+ } else {
+ printf("FAIL - failed finding encoding 'csinvariant'\n");
+ return 1;
+ }
+
c = parserutils_charset_alias_canonicalise("nats-sefi-add", 13);
if (c) {
printf("%s %d\n", c->name, c->mib_enum);