[recipes] Be more strict when generating IDs
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Be more strict when generating IDs
- Date: Sat, 25 Feb 2017 15:07:06 +0000 (UTC)
commit 15056925f633ec97d8886bcbf35e640b39893ab2
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 25 10:04:18 2017 -0500
Be more strict when generating IDs
The CSS spec does not allow non-alphanumeric ASCII in identifiers,
so replace them with _.
https://bugzilla.gnome.org/show_bug.cgi?id=779176
src/gr-utils.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 0b6e0f5..bc95230 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -376,11 +376,12 @@ generate_id (const char *first_string, ...)
while (s) {
for (q = s; *q; q = g_utf8_find_next_char (q, NULL)) {
gunichar ch = g_utf8_get_char (q);
- if (ch > 128 || ch == '.' || ch == ',' || ch == ' ' ||
- ch == ']' || ch == '[' || g_ascii_iscntrl ((char)ch))
- g_string_append_c (str, '_');
+ if (ch > 128 ||
+ g_ascii_isalnum (ch) || g_ascii_isdigit (ch) ||
+ (char)ch == '-' || (char)ch == '_')
+ g_string_append_unichar (str, ch);
else
- g_string_append_c (str, (char)ch);
+ g_string_append_c (str, '_');
}
s = va_arg (ap, const char *);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]