Copy XkbEnsureSafeMapName from xkbfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/include/X11/extensions/XKBcommon.h b/include/X11/extensions/XKBcommon.h
index e29d5c7..37a098c 100644
--- a/include/X11/extensions/XKBcommon.h
+++ b/include/X11/extensions/XKBcommon.h
@@ -305,6 +305,9 @@ extern Bool
XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
unsigned char *map_rtrn);
+extern void
+XkbcEnsureSafeMapName(char *name);
+
_XFUNCPROTOEND
#endif /* _XKBCOMMON_H_ */
diff --git a/src/misc.c b/src/misc.c
index f294d69..5c8e19a 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -160,3 +160,27 @@ XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
*mask_rtrn = mask;
return True;
}
+
+/*
+ * All latin-1 alphanumerics, plus parens, slash, minus, underscore and
+ * wildcards.
+ */
+static unsigned char componentSpecLegal[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x83,
+ 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff
+};
+
+void
+XkbcEnsureSafeMapName(char *name)
+{
+ if (!name)
+ return;
+
+ while (*name!='\0') {
+ if ((componentSpecLegal[(*name) / 8] & (1 << ((*name) % 8))) == 0)
+ *name= '_';
+ name++;
+ }
+}
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index 2e10798..cbb35d9 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -809,7 +809,7 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags)
file = uTypedAlloc(XkbFile);
if (file)
{
- XkbEnsureSafeMapName(name);
+ XkbcEnsureSafeMapName(name);
bzero(file, sizeof(XkbFile));
file->type = type;
file->topName = uStringDup(name);