Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-12-09 08:52:53 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-12-09 08:56:08 +0300
commit9d8aefaa5c5e2c3ed90e2fc1f6a9756f7444aa67 (patch)
tree90020151f0380a1144c49d38d484765951e47e99
parentceba6b2c2161bda2e56bef7252782e0722579e95 (diff)
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.
-rw-r--r--source/blender/makesrna/intern/rna_access.c18
1 files changed, 13 insertions, 5 deletions
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;