[Bf-blender-cvs] [9d8aefaa5c5] master: Fix RNA un-escaping multiple slashes and strings ending with a slash
Campbell Barton
noreply at git.blender.org
Wed Dec 9 07:05:15 CET 2020
Commit: 9d8aefaa5c5e2c3ed90e2fc1f6a9756f7444aa67
Author: Campbell Barton
Date: Wed Dec 9 16:52:53 2020 +1100
Branches: master
https://developer.blender.org/rB9d8aefaa5c5e2c3ed90e2fc1f6a9756f7444aa67
Fix RNA un-escaping multiple slashes and strings ending with a slash
Fix for T78823 resolved the issue reported but didn't
properly support multiple back-slashes.
===================================================================
M source/blender/makesrna/intern/rna_access.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index a7f326bc79e..1aac9c0c0c2 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -4993,7 +4993,9 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
len++;
p++;
while (*p && (*p != quote || escape)) {
- escape = (*p == '\\');
+ /* A pair of back-slashes represents a single back-slash,
+ * only use a single back-slash for escaping. */
+ escape = (escape == 0) && (*p == '\\');
len++;
p++;
}
@@ -5033,11 +5035,17 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
/* copy string, taking into account escaped ] */
if (bracket) {
for (p = *path, i = 0, j = 0; i < len; i++, p++) {
- if (*p == '\\' && ELEM(*(p + 1), quote, '\\')) {
- }
- else {
- buf[j++] = *p;
+ if (*p == '\\') {
+ if (*(p + 1) == '\\') {
+ /* Un-escape pairs of back-slashes into a single back-slash. */
+ p++;
+ i += 1;
+ }
+ else if (*(p + 1) == quote) {
+ continue;
+ }
}
+ buf[j++] = *p;
}
buf[j] = 0;
More information about the Bf-blender-cvs
mailing list