fix [#34958] keyframe many items would fail if there was a (") in the text.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 23 Apr 2013 20:10:22 +0000 (20:10 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 23 Apr 2013 20:10:22 +0000 (20:10 +0000)
25 files changed:
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/linestyle.c
source/blender/editors/animation/drivers.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_boid.c
source/blender/makesrna/intern/rna_cloth.c
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_dynamicpaint.c
source/blender/makesrna/intern/rna_fluidsim.c
source/blender/makesrna/intern/rna_key.c
source/blender/makesrna/intern/rna_linestyle.c
source/blender/makesrna/intern/rna_mask.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nla.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_pose.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_sequencer.c
source/blender/makesrna/intern/rna_smoke.c
source/blender/makesrna/intern/rna_texture.c
source/blender/makesrna/intern/rna_tracking.c

index 48d83652f562653514f5657bcc8136ffa82b8cfa..f3d5b838a0d57331d426986e59ad2cf7b67575b2 100644 (file)
@@ -745,7 +745,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons
        /* NLA Data - Animation Data for Strips */
        for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next)
                nlastrips_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &nlt->strips, verify_paths);
-               
+
        /* free the temp names */
        MEM_freeN(oldN);
        MEM_freeN(newN);
index 6a8061274f8f6db49fc94d474d5f4ccf47b40e89..05ceb8f76ea08b5aba9d11002a618e503fd1f74f 100644 (file)
@@ -1018,25 +1018,29 @@ char *BKE_path_from_ID_to_color_ramp(FreestyleLineStyle *linestyle, ColorBand *c
 
        for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
                switch (m->type) {
-               case LS_MODIFIER_ALONG_STROKE:
-                       if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp)
-                               found = true;
-                       break;
-               case LS_MODIFIER_DISTANCE_FROM_CAMERA:
-                       if (color_ramp == ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp)
-                               found = true;
-                       break;
-               case LS_MODIFIER_DISTANCE_FROM_OBJECT:
-                       if (color_ramp == ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp)
-                               found = true;
-                       break;
-               case LS_MODIFIER_MATERIAL:
-                       if (color_ramp == ((LineStyleColorModifier_Material *)m)->color_ramp)
-                               found = true;
-                       break;
+                       case LS_MODIFIER_ALONG_STROKE:
+                               if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp)
+                                       found = true;
+                               break;
+                       case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+                               if (color_ramp == ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp)
+                                       found = true;
+                               break;
+                       case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+                               if (color_ramp == ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp)
+                                       found = true;
+                               break;
+                       case LS_MODIFIER_MATERIAL:
+                               if (color_ramp == ((LineStyleColorModifier_Material *)m)->color_ramp)
+                                       found = true;
+                               break;
+               }
+
+               if (found) {
+                       char name_esc[sizeof(m->name) * 2];
+                       BLI_strescape(name_esc, m->name, sizeof(name_esc));
+                       return BLI_sprintfN("color_modifiers[\"%s\"].color_ramp", name_esc);
                }
-               if (found)
-                       return BLI_sprintfN("color_modifiers[\"%s\"].color_ramp", m->name);
        }
        printf("BKE_path_from_ID_to_color_ramp: No color ramps correspond to the given pointer.\n");
        return NULL;
index d9965ebdcacc16db18d0f203794ba4e2f5720682..ef15e2540486f22df25eb017a5fbe416a0f4e2ff 100644 (file)
@@ -434,11 +434,17 @@ static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *pro
                                        
                                        /* assumes: texture will only be shown if it is active material's active texture it's ok */
                                        if ((ID *)tex == id) {
+                                               char name_esc_ma[(sizeof(ma->id.name) - 2) * 2];
+                                               char name_esc_tex[(sizeof(tex->id.name) - 2) * 2];
+
+                                               BLI_strescape(name_esc_ma, ma->id.name + 2, sizeof(name_esc_ma));
+                                               BLI_strescape(name_esc_tex, tex->id.name + 2, sizeof(name_esc_tex));
+
                                                /* create new path */
                                                // TODO: use RNA path functions to construct step by step instead?
                                                // FIXME: maybe this isn't even needed anymore...
                                                path = BLI_sprintfN("material_slots[\"%s\"].material.texture_slots[\"%s\"].texture.%s", 
-                                                                   ma->id.name + 2, tex->id.name + 2, basepath);
+                                                                   name_esc_ma, name_esc_tex, basepath);
                                                        
                                                /* free old one */
                                                MEM_freeN(basepath);
index 9a102c823a9196ed853742849f22a42b675bf038..cfdfbf4e6878db89954489faa26c3eb82ab0df36 100644 (file)
@@ -4325,14 +4325,25 @@ char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
        propname = RNA_property_identifier(prop);
 
        if (ptrpath) {
-               path = BLI_sprintfN(is_rna ? "%s.%s" : "%s[\"%s\"]", ptrpath, propname);
+               if (is_rna) {
+                       path = BLI_sprintfN("%s.%s", ptrpath, propname);
+               }
+               else {
+                       char propname_esc[MAX_IDPROP_NAME * 2];
+                       BLI_strescape(propname_esc, propname, sizeof(propname_esc));
+                       path = BLI_sprintfN("%s[\"%s\"]", ptrpath, propname_esc);
+               }
                MEM_freeN(ptrpath);
        }
        else if (RNA_struct_is_ID(ptr->type)) {
-               if (is_rna)
+               if (is_rna) {
                        path = BLI_strdup(propname);
-               else
-                       path = BLI_sprintfN("[\"%s\"]", propname);
+               }
+               else {
+                       char propname_esc[MAX_IDPROP_NAME * 2];
+                       BLI_strescape(propname_esc, propname, sizeof(propname_esc));
+                       path = BLI_sprintfN("[\"%s\"]", propname_esc);
+               }
        }
        else {
                path = NULL;
index 1bc6c7e4f6fec2bb87e457a8c85a08c3571f862d..b222dd9148bdf5b25cea69c513eee1fa02493301 100644 (file)
@@ -191,20 +191,23 @@ static void rna_Bone_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
 
 static char *rna_Bone_path(PointerRNA *ptr)
 {
+       ID *id = ptr->id.data;
        Bone *bone = (Bone *)ptr->data;
+       char name_esc[sizeof(bone->name) * 2];
        
+       BLI_strescape(name_esc, bone->name, sizeof(name_esc));
+
        /* special exception for trying to get the path where ID-block is Object
-        *      - this will be assumed to be from a Pose Bone...
+        * - this will be assumed to be from a Pose Bone...
         */
-       if (ptr->id.data) {
-               ID *id = (ID *)ptr->id.data;
-               
-               if (GS(id->name) == ID_OB)
-                       return BLI_sprintfN("pose.bones[\"%s\"].bone", bone->name);
+       if (id) {
+               if (GS(id->name) == ID_OB) {
+                       return BLI_sprintfN("pose.bones[\"%s\"].bone", name_esc);
+               }
        }
        
        /* from armature... */
-       return BLI_sprintfN("bones[\"%s\"]", bone->name);
+       return BLI_sprintfN("bones[\"%s\"]", name_esc);
 }
 
 static IDProperty *rna_Bone_idprops(PointerRNA *ptr, bool create)
index 9d44ae87b574451c0de396083401c4405d9a0e6e..9b2ce86310867d1c7612ab3c2a8d57e0bfae4ab0 100644 (file)
@@ -142,7 +142,12 @@ static StructRNA *rna_BoidRule_refine(struct PointerRNA *ptr)
 
 static char *rna_BoidRule_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("rules[\"%s\"]", ((BoidRule *)ptr->data)->name);  /* XXX not unique */
+       BoidRule *rule = (BoidRule *)ptr->data;
+       char name_esc[sizeof(rule->name) * 2];
+
+       BLI_strescape(name_esc, rule->name, sizeof(name_esc));
+
+       return BLI_sprintfN("rules[\"%s\"]", name_esc);  /* XXX not unique */
 }
 
 static PointerRNA rna_BoidState_active_boid_rule_get(PointerRNA *ptr)
index 74b0f69c9b8f7df8834807424a71fcdf64f01d95..d5c63800aea621b18a08f075e0f7c2f8a9b87910 100644 (file)
@@ -212,7 +212,14 @@ static char *rna_ClothSettings_path(PointerRNA *ptr)
        Object *ob = (Object *)ptr->id.data;
        ModifierData *md = modifiers_findByType(ob, eModifierType_Cloth);
 
-       return md ? BLI_sprintfN("modifiers[\"%s\"].settings", md->name) : NULL;
+       if (md) {
+               char name_esc[sizeof(md->name) * 2];
+               BLI_strescape(name_esc, md->name, sizeof(name_esc));
+               return BLI_sprintfN("modifiers[\"%s\"].settings", name_esc);
+       }
+       else {
+               return NULL;
+       }
 }
 
 static char *rna_ClothCollisionSettings_path(PointerRNA *ptr)
@@ -220,7 +227,14 @@ static char *rna_ClothCollisionSettings_path(PointerRNA *ptr)
        Object *ob = (Object *)ptr->id.data;
        ModifierData *md = modifiers_findByType(ob, eModifierType_Cloth);
 
-       return md ? BLI_sprintfN("modifiers[\"%s\"].collision_settings", md->name) : NULL;
+       if (md) {
+               char name_esc[sizeof(md->name) * 2];
+               BLI_strescape(name_esc, md->name, sizeof(name_esc));
+               return BLI_sprintfN("modifiers[\"%s\"].collision_settings", name_esc);
+       }
+       else {
+               return NULL;
+       }
 }
 
 #else
index c96ea72fee2c4dd1bd18068d2fefb902ad54c9f3..05d4c5a59d22b4fcd9155932e89121e50cd40fc9 100644 (file)
@@ -251,14 +251,21 @@ static char *rna_Constraint_path(PointerRNA *ptr)
        ListBase *lb = get_constraint_lb(ob, con, &pchan);
 
        if (lb == NULL)
-               printf("rna_Constraint_path: internal error, constraint '%s' not found in object '%s'\n",
-                      con->name, ob->id.name);
+               printf("%s: internal error, constraint '%s' not found in object '%s'\n",
+                      __func__, con->name, ob->id.name);
 
        if (pchan) {
-               return BLI_sprintfN("pose.bones[\"%s\"].constraints[\"%s\"]", pchan->name, con->name);
+               char name_esc_pchan[sizeof(pchan->name) * 2];
+               char name_esc_const[sizeof(con->name) * 2];
+               BLI_strescape(name_esc_pchan, pchan->name, sizeof(name_esc_pchan));
+               BLI_strescape(name_esc_const, con->name,   sizeof(name_esc_const));
+               return BLI_sprintfN("pose.bones[\"%s\"].constraints[\"%s\"]", name_esc_pchan, name_esc_const);
+       }
+       else {
+               char name_esc_const[sizeof(con->name) * 2];
+               BLI_strescape(name_esc_const, con->name,   sizeof(name_esc_const));
+               return BLI_sprintfN("constraints[\"%s\"]", name_esc_const);
        }
-       
-       return BLI_sprintfN("constraints[\"%s\"]", con->name);
 }
 
 static void rna_Constraint_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
index 1e5bcad13843e17b2207bdd1573358cf701d7af3..900ae5122ef461367efbb538f59c9d0099c8c89f 100644 (file)
@@ -62,24 +62,32 @@ static char *rna_DynamicPaintCanvasSettings_path(PointerRNA *ptr)
 {
        DynamicPaintCanvasSettings *settings = (DynamicPaintCanvasSettings *)ptr->data;
        ModifierData *md = (ModifierData *)settings->pmd;
+       char name_esc[sizeof(md->name) * 2];
 
-       return BLI_sprintfN("modifiers[\"%s\"].canvas_settings", md->name);
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       return BLI_sprintfN("modifiers[\"%s\"].canvas_settings", name_esc);
 }
 
 static char *rna_DynamicPaintBrushSettings_path(PointerRNA *ptr)
 {
        DynamicPaintBrushSettings *settings = (DynamicPaintBrushSettings *)ptr->data;
        ModifierData *md = (ModifierData *)settings->pmd;
+       char name_esc[sizeof(md->name) * 2];
 
-       return BLI_sprintfN("modifiers[\"%s\"].brush_settings", md->name);
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       return BLI_sprintfN("modifiers[\"%s\"].brush_settings", name_esc);
 }
 
 static char *rna_DynamicPaintSurface_path(PointerRNA *ptr)
 {
        DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
        ModifierData *md = (ModifierData *)surface->canvas->pmd;
+       char name_esc[sizeof(md->name) * 2];
+       char name_esc_surface[sizeof(surface->name) * 2];
 
-       return BLI_sprintfN("modifiers[\"%s\"].canvas_settings.canvas_surfaces[\"%s\"]", md->name, surface->name);
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       BLI_strescape(name_esc_surface, surface->name, sizeof(name_esc_surface));
+       return BLI_sprintfN("modifiers[\"%s\"].canvas_settings.canvas_surfaces[\"%s\"]", name_esc, name_esc_surface);
 }
 
 
index 45ce3676b5af006fa25375262de6819faa113d45..923e52e29c0bf734a0307901391db1fa1723e643 100644 (file)
@@ -197,8 +197,10 @@ static char *rna_FluidSettings_path(PointerRNA *ptr)
 {
        FluidsimSettings *fss = (FluidsimSettings *)ptr->data;
        ModifierData *md = (ModifierData *)fss->fmd;
+       char name_esc[sizeof(md->name) * 2];
 
-       return BLI_sprintfN("modifiers[\"%s\"].settings", md->name);
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       return BLI_sprintfN("modifiers[\"%s\"].settings", name_esc);
 }
 
 static void rna_FluidMeshVertex_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
index b84436820b8d7ba02786efe8a7ff53c7694871bf..4e8b8d7b1a7828a450c6bba9132138e09accd19e 100644 (file)
@@ -351,11 +351,14 @@ static char *rna_ShapeKey_path(PointerRNA *ptr)
 {
        KeyBlock *kb = (KeyBlock *)ptr->data;
        ID *id = ptr->id.data;
-       
+       char name_esc[sizeof(kb->name) * 2];
+
+       BLI_strescape(name_esc, kb->name, sizeof(name_esc));
+
        if ((id) && (GS(id->name) != ID_KE))
-               return BLI_sprintfN("shape_keys.key_blocks[\"%s\"]", kb->name);
+               return BLI_sprintfN("shape_keys.key_blocks[\"%s\"]", name_esc);
        else
-               return BLI_sprintfN("key_blocks[\"%s\"]", kb->name);
+               return BLI_sprintfN("key_blocks[\"%s\"]", name_esc);
 }
 
 static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
@@ -436,12 +439,15 @@ static char *rna_ShapeKeyPoint_path(PointerRNA *ptr)
        kb = rna_ShapeKeyData_find_keyblock(key, point);
        
        if (kb) {
+               char name_esc_kb[sizeof(kb->name) * 2];
                int index = rna_ShapeKeyPoint_get_index(key, kb, point);
+
+               BLI_strescape(name_esc_kb, kb->name, sizeof(name_esc_kb));
                
                if (GS(id->name) == ID_KE)
-                       return BLI_sprintfN("key_blocks[\"%s\"].data[%d]", kb->name, index);
+                       return BLI_sprintfN("key_blocks[\"%s\"].data[%d]", name_esc_kb, index);
                else
-                       return BLI_sprintfN("shape_keys.key_blocks[\"%s\"].data[%d]", kb->name, index);
+                       return BLI_sprintfN("shape_keys.key_blocks[\"%s\"].data[%d]", name_esc_kb, index);
        }
        else
                return NULL;  /* XXX: there's really no way to resolve this... */
index 5db9329cd272a47e6e4ca371597a166f2a3c10ab..660ef57dbfe3ea5a743969b044ecd550cb93197d 100644 (file)
@@ -179,22 +179,34 @@ static StructRNA *rna_LineStyle_geometry_modifier_refine(struct PointerRNA *ptr)
 
 static char *rna_LineStyle_color_modifier_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("color_modifiers[\"%s\"]", ((LineStyleModifier *)ptr->data)->name);
+       LineStyleModifier *m = (LineStyleModifier *)ptr->data;
+       char name_esc[sizeof(m->name) * 2];
+       BLI_strescape(name_esc, m->name, sizeof(name_esc));
+       return BLI_sprintfN("color_modifiers[\"%s\"]", name_esc);
 }
 
 static char *rna_LineStyle_alpha_modifier_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("alpha_modifiers[\"%s\"]", ((LineStyleModifier *)ptr->data)->name);
+       LineStyleModifier *m = (LineStyleModifier *)ptr->data;
+       char name_esc[sizeof(m->name) * 2];
+       BLI_strescape(name_esc, m->name, sizeof(name_esc));
+       return BLI_sprintfN("alpha_modifiers[\"%s\"]", name_esc);
 }
 
 static char *rna_LineStyle_thickness_modifier_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("thickness_modifiers[\"%s\"]", ((LineStyleModifier *)ptr->data)->name);
+       LineStyleModifier *m = (LineStyleModifier *)ptr->data;
+       char name_esc[sizeof(m->name) * 2];
+       BLI_strescape(name_esc, m->name, sizeof(name_esc));
+       return BLI_sprintfN("thickness_modifiers[\"%s\"]", name_esc);
 }
 
 static char *rna_LineStyle_geometry_modifier_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("geometry_modifiers[\"%s\"]", ((LineStyleModifier *)ptr->data)->name);
+       LineStyleModifier *m = (LineStyleModifier *)ptr->data;
+       char name_esc[sizeof(m->name) * 2];
+       BLI_strescape(name_esc, m->name, sizeof(name_esc));
+       return BLI_sprintfN("geometry_modifiers[\"%s\"]", name_esc);
 }
 
 static void rna_LineStyleColorModifier_name_set(PointerRNA *ptr, const char *value)
index c47b81ec9caddde2362bbb26e68f28a237fb55f8..6d43f529e65bfa01b3190fb26cc313fae620000c 100644 (file)
@@ -168,7 +168,10 @@ static void rna_Mask_layer_active_index_range(PointerRNA *ptr, int *min, int *ma
 
 static char *rna_MaskLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("layers[\"%s\"]", ((MaskLayer *)ptr->data)->name);
+       MaskLayer *masklay = (MaskLayer *)ptr->data;
+       char name_esc[sizeof(masklay->name) * 2];
+       BLI_strescape(name_esc, masklay->name, sizeof(name_esc));
+       return BLI_sprintfN("layers[\"%s\"]", name_esc);
 }
 
 static PointerRNA rna_Mask_layer_active_get(PointerRNA *ptr)
index be058bbfb4c1d07afdcc9763f557267c20049978..c5160cbd6e0625d45127af7859d6384532afad98 100644 (file)
@@ -562,7 +562,10 @@ DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(uv_layer, ldata, CD_MLOOPUV, rende
 
 static char *rna_MeshUVLoopLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("uv_layers[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("uv_layers[\"%s\"]", name_esc);
 }
 
 static void rna_MeshUVLoopLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -879,7 +882,10 @@ DEFINE_CUSTOMDATA_LAYER_COLLECTION(skin_vertice, vdata, CD_MVERT_SKIN);
 
 static char *rna_MeshSkinVertexLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("skin_vertices[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("skin_vertices[\"%s\"]", name_esc);
 }
 
 static char *rna_VertCustomData_data_path(PointerRNA *ptr, char *collection, int type);
@@ -1101,12 +1107,18 @@ static char *rna_MeshVertex_path(PointerRNA *ptr)
 
 static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("tessface_uv_textures[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("tessface_uv_textures[\"%s\"]", name_esc);
 }
 
 static char *rna_MeshTexturePolyLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("uv_textures[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("uv_textures[\"%s\"]", name_esc);
 }
 
 static char *rna_VertCustomData_data_path(PointerRNA *ptr, char *collection, int type)
@@ -1119,8 +1131,11 @@ static char *rna_VertCustomData_data_path(PointerRNA *ptr, char *collection, int
        for (cdl = vdata->layers, a = 0; a < vdata->totlayer; cdl++, a++) {
                if (cdl->type == type) {
                        b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
-                       if (b >= 0 && b < totvert)
-                               return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, cdl->name, b);
+                       if (b >= 0 && b < totvert) {
+                               char name_esc[sizeof(cdl->name) * 2];
+                               BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+                               return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b);
+                       }
                }
        }
 
@@ -1137,8 +1152,11 @@ static char *rna_PolyCustomData_data_path(PointerRNA *ptr, char *collection, int
        for (cdl = pdata->layers, a = 0; a < pdata->totlayer; cdl++, a++) {
                if (cdl->type == type) {
                        b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
-                       if (b >= 0 && b < totpoly)
-                               return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, cdl->name, b);
+                       if (b >= 0 && b < totpoly) {
+                               char name_esc[sizeof(cdl->name) * 2];
+                               BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+                               return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b);
+                       }
                }
        }
 
@@ -1155,8 +1173,11 @@ static char *rna_LoopCustomData_data_path(PointerRNA *ptr, char *collection, int
        for (cdl = ldata->layers, a = 0; a < ldata->totlayer; cdl++, a++) {
                if (cdl->type == type) {
                        b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
-                       if (b >= 0 && b < totloop)
-                               return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, cdl->name, b);
+                       if (b >= 0 && b < totloop) {
+                               char name_esc[sizeof(cdl->name) * 2];
+                               BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+                               return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b);
+                       }
                }
        }
 
@@ -1173,8 +1194,11 @@ static char *rna_FaceCustomData_data_path(PointerRNA *ptr, char *collection, int
        for (cdl = fdata->layers, a = 0; a < fdata->totlayer; cdl++, a++) {
                if (cdl->type == type) {
                        b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
-                       if (b >= 0 && b < totloop)
-                               return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, cdl->name, b);
+                       if (b >= 0 && b < totloop) {
+                               char name_esc[sizeof(cdl->name) * 2];
+                               BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+                               return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b);
+                       }
                }
        }
 
@@ -1198,12 +1222,18 @@ static char *rna_MeshTexturePoly_path(PointerRNA *ptr)
 
 static char *rna_MeshColorLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("tessface_vertex_colors[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("tessface_vertex_colors[\"%s\"]", name_esc);
 }
 
 static char *rna_MeshLoopColorLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("vertex_colors[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("vertex_colors[\"%s\"]", name_esc);
 }
 
 static char *rna_MeshColor_path(PointerRNA *ptr)
@@ -1213,7 +1243,10 @@ static char *rna_MeshColor_path(PointerRNA *ptr)
 
 static char *rna_MeshIntPropertyLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("int_layers[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("int_layers[\"%s\"]", name_esc);
 }
 
 static char *rna_MeshIntProperty_path(PointerRNA *ptr)
@@ -1223,7 +1256,10 @@ static char *rna_MeshIntProperty_path(PointerRNA *ptr)
 
 static char *rna_MeshFloatPropertyLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("float_layers[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("float_layers[\"%s\"]", name_esc);
 }
 
 static char *rna_MeshFloatProperty_path(PointerRNA *ptr)
@@ -1233,7 +1269,10 @@ static char *rna_MeshFloatProperty_path(PointerRNA *ptr)
 
 static char *rna_MeshStringPropertyLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("string_layers[\"%s\"]", ((CustomDataLayer *)ptr->data)->name);
+       CustomDataLayer *cdl = ptr->data;
+       char name_esc[sizeof(cdl->name) * 2];
+       BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+       return BLI_sprintfN("string_layers[\"%s\"]", name_esc);
 }
 
 static char *rna_MeshStringProperty_path(PointerRNA *ptr)
index 618feae57d46d66b2d20317bc99ac90af69e107d..d84c3fa039f7985a523259122b8a535d99ed5c05 100644 (file)
@@ -255,7 +255,11 @@ static void rna_Modifier_name_set(PointerRNA *ptr, const char *value)
 
 static char *rna_Modifier_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("modifiers[\"%s\"]", ((ModifierData *)ptr->data)->name);
+       ModifierData *md = ptr->data;
+       char name_esc[sizeof(md->name) * 2];
+
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       return BLI_sprintfN("modifiers[\"%s\"]", name_esc);
 }
 
 static void rna_Modifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
index 9afaad960197ba2bb47ac508d23a0e0a0d4ef26b..3bf6c11d9359e7c5d5206614d498aae993f5ec0b 100644 (file)
@@ -84,7 +84,13 @@ static char *rna_NlaStrip_path(PointerRNA *ptr)
                        for (nls = nlt->strips.first; nls; nls = nls->next) {
                                if (nls == strip) {
                                        /* XXX but if we animate like this, the control will never work... */
-                                       return BLI_sprintfN("animation_data.nla_tracks[\"%s\"].strips[\"%s\"]", nlt->name, strip->name);
+                                       char name_esc_nlt[sizeof(nlt->name) * 2];
+                                       char name_esc_strip[sizeof(strip->name) * 2];
+
+                                       BLI_strescape(name_esc_nlt, nlt->name, sizeof(name_esc_nlt));
+                                       BLI_strescape(name_esc_strip, strip->name, sizeof(name_esc_strip));
+                                       return BLI_sprintfN("animation_data.nla_tracks[\"%s\"].strips[\"%s\"]",
+                                                           name_esc_nlt, name_esc_strip);
                                }
                        }
                }
index 85c3c9d6b65e7d3722e77df80e8f5312cea50045..fad66a5e7edac877163dc0c687712a7429193759 100644 (file)
@@ -1071,8 +1071,10 @@ static StructRNA *rna_Node_refine(struct PointerRNA *ptr)
 static char *rna_Node_path(PointerRNA *ptr)
 {
        bNode *node = (bNode *)ptr->data;
+       char name_esc[sizeof(node->name) * 2];
 
-       return BLI_sprintfN("nodes[\"%s\"]", node->name);
+       BLI_strescape(name_esc, node->name, sizeof(name_esc));
+       return BLI_sprintfN("nodes[\"%s\"]", name_esc);
 }
 
 static int rna_Node_poll(bNodeType *ntype, bNodeTree *ntree)
@@ -1818,16 +1820,19 @@ static char *rna_NodeSocket_path(PointerRNA *ptr)
        bNodeSocket *sock = (bNodeSocket *)ptr->data;
        bNode *node;
        int socketindex;
+       char name_esc[sizeof(node->name) * 2];
        
        if (!nodeFindNode(ntree, sock, &node, &socketindex))
                return NULL;
        
-       if (sock->in_out == SOCK_IN)
-               return BLI_sprintfN("nodes[\"%s\"].inputs[%d]", node->name, socketindex);
-       else
-               return BLI_sprintfN("nodes[\"%s\"].outputs[%d]", node->name, socketindex);
-       
-       return NULL;
+       BLI_strescape(name_esc, node->name, sizeof(name_esc));
+
+       if (sock->in_out == SOCK_IN) {
+               return BLI_sprintfN("nodes[\"%s\"].inputs[%d]", name_esc, socketindex);
+       }
+       else {
+               return BLI_sprintfN("nodes[\"%s\"].outputs[%d]", name_esc, socketindex);
+       }
 }
 
 static IDProperty *rna_NodeSocket_idprops(PointerRNA *ptr, bool create)
index ab8b54334feb312f8e941b1bf75c1834171177bb..2d3f2ddf6992a4400125f0ac76de3dc7bcfdf491 100644 (file)
@@ -320,7 +320,10 @@ static char *rna_CollisionSettings_path(PointerRNA *UNUSED(ptr))
        ModifierData *md = (ModifierData *)modifiers_findByType(ob, eModifierType_Collision);
 
        if (md) {
-               return BLI_sprintfN("modifiers[\"%s\"].settings", md->name);
+               char name_esc[sizeof(md->name) * 2];
+
+               BLI_strescape(name_esc, md->name, sizeof(name_esc));
+               return BLI_sprintfN("modifiers[\"%s\"].settings", name_esc);
        }
        else {
                return BLI_strdup("");
@@ -462,8 +465,10 @@ static char *rna_SoftBodySettings_path(PointerRNA *ptr)
 {
        Object *ob = (Object *)ptr->id.data;
        ModifierData *md = (ModifierData *)modifiers_findByType(ob, eModifierType_Softbody);
-       
-       return BLI_sprintfN("modifiers[\"%s\"].settings", md->name);
+       char name_esc[sizeof(md->name) * 2];
+
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       return BLI_sprintfN("modifiers[\"%s\"].settings", name_esc);
 }
 
 static int particle_id_check(PointerRNA *ptr)
@@ -613,13 +618,16 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
        else {
                Object *ob = (Object *)ptr->id.data;
                ModifierData *md;
+               char name_esc[sizeof(md->name) * 2];
+
+               BLI_strescape(name_esc, md->name, sizeof(name_esc));
                
                /* check softbody modifier */
                md = (ModifierData *)modifiers_findByType(ob, eModifierType_Softbody);
                if (md) {
                        /* no pointer from modifier data to actual softbody storage, would be good to add */
                        if (ob->soft->effector_weights == ew)
-                               return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", md->name);
+                               return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", name_esc);
                }
                
                /* check cloth modifier */
@@ -628,7 +636,7 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
                        ClothModifierData *cmd = (ClothModifierData *)md;
                        
                        if (cmd->sim_parms->effector_weights == ew)
-                               return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", md->name);
+                               return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", name_esc);
                }
                
                /* check smoke modifier */
@@ -637,7 +645,7 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
                        SmokeModifierData *smd = (SmokeModifierData *)md;
                        
                        if (smd->domain->effector_weights == ew)
-                               return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", md->name);
+                               return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", name_esc);
                }
 
                /* check dynamic paint modifier */
@@ -649,9 +657,13 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
                                DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
 
                                for (; surface; surface = surface->next) {
-                                       if (surface->effector_weights == ew)
+                                       if (surface->effector_weights == ew) {
+                                               char name_esc_surface[sizeof(surface->name) * 2];
+
+                                               BLI_strescape(name_esc_surface, surface->name, sizeof(name_esc_surface));
                                                return BLI_sprintfN("modifiers[\"%s\"].canvas_settings.canvas_surfaces[\"%s\"]"
-                                                                   ".effector_weights", md->name, surface->name);
+                                                                   ".effector_weights", name_esc, name_esc_surface);
+                                       }
                                }
                        }
                }
index 9208f1273fc783adb679e38e002e20bfa1d5adac..140b9d74d06e169eb104088f1f4ab5aeaeb1ad75 100644 (file)
@@ -1196,7 +1196,10 @@ static void psys_vg_name_set__internal(PointerRNA *ptr, const char *value, int i
 static char *rna_ParticleSystem_path(PointerRNA *ptr)
 {
        ParticleSystem *psys = (ParticleSystem *)ptr->data;
-       return BLI_sprintfN("particle_systems[\"%s\"]", psys->name);
+       char name_esc[sizeof(psys->name) * 2];
+
+       BLI_strescape(name_esc, psys->name, sizeof(name_esc));
+       return BLI_sprintfN("particle_systems[\"%s\"]", name_esc);
 }
 
 static void rna_ParticleSettings_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
index 0a19d7b5250f2e7ba7c20a805617d9ad064dca6b..8c73aacc7247ab17b0efc352cf5503212fe10d8c 100644 (file)
@@ -133,7 +133,11 @@ static void rna_Pose_IK_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
 
 static char *rna_PoseBone_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("pose.bones[\"%s\"]", ((bPoseChannel *)ptr->data)->name);
+       bPoseChannel *pchan = ptr->data;
+       char name_esc[sizeof(pchan->name) * 2];
+
+       BLI_strescape(name_esc, pchan->name, sizeof(name_esc));
+       return BLI_sprintfN("pose.bones[\"%s\"]", name_esc);
 }
 
 /* shared for actions groups and bone groups */
index e589bde07440ec4d2b1c64c700f343d6f4b49646..0d224469b4e473fe74905afcd8727880834cae02 100644 (file)
@@ -1138,7 +1138,10 @@ static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value)
 static char *rna_SceneRenderLayer_path(PointerRNA *ptr)
 {
        SceneRenderLayer *srl = (SceneRenderLayer *)ptr->data;
-       return BLI_sprintfN("render.layers[\"%s\"]", srl->name);
+       char name_esc[sizeof(srl->name) * 2];
+
+       BLI_strescape(name_esc, srl->name, sizeof(name_esc));
+       return BLI_sprintfN("render.layers[\"%s\"]", name_esc);
 }
 
 static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
index 4d7856110388efd13c4c12467a92ea1147c1f1de..e522b73039bbef599e71faa159e8c96c04710b87 100644 (file)
@@ -342,10 +342,15 @@ static char *rna_SequenceTransform_path(PointerRNA *ptr)
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
        Sequence *seq = sequence_get_by_transform(ed, ptr->data);
 
-       if (seq && seq->name + 2)
-               return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform", seq->name + 2);
-       else
+       if (seq && seq->name + 2) {
+               char name_esc[(sizeof(seq->name) - 2) * 2];
+
+               BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
+               return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform", name_esc);
+       }
+       else {
                return BLI_strdup("");
+       }
 }
 
 static void rna_SequenceTransform_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -387,10 +392,15 @@ static char *rna_SequenceCrop_path(PointerRNA *ptr)
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
        Sequence *seq = sequence_get_by_crop(ed, ptr->data);
 
-       if (seq && seq->name + 2)
-               return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop", seq->name + 2);
-       else
+       if (seq && seq->name + 2) {
+               char name_esc[(sizeof(seq->name) - 2) * 2];
+
+               BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
+               return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop", name_esc);
+       }
+       else {
                return BLI_strdup("");
+       }
 }
 
 static void rna_SequenceCrop_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -501,10 +511,15 @@ static char *rna_Sequence_path(PointerRNA *ptr)
        /* sequencer data comes from scene...
         * TODO: would be nice to make SequenceEditor data a datablock of its own (for shorter paths)
         */
-       if (seq->name + 2)
-               return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"]", seq->name + 2);
-       else
+       if (seq->name + 2) {
+               char name_esc[(sizeof(seq->name) - 2) * 2];
+
+               BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
+               return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"]", name_esc);
+       }
+       else {
                return BLI_strdup("");
+       }
 }
 
 static PointerRNA rna_SequenceEditor_meta_stack_get(CollectionPropertyIterator *iter)
@@ -754,13 +769,23 @@ static char *rna_SequenceColorBalance_path(PointerRNA *ptr)
        Sequence *seq = sequence_get_by_colorbalance(ed, ptr->data, &smd);
 
        if (seq && seq->name + 2) {
+               char name_esc[(sizeof(seq->name) - 2) * 2];
+
+               BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
+
                if (!smd) {
                        /* path to old filter color balance */
-                       return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].color_balance", seq->name + 2);
+                       return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].color_balance", name_esc);
                }
                else {
                        /* path to modifier */
-                       return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].modifiers[\"%s\"].color_balance", seq->name + 2, smd->name);
+                       char name_esc[(sizeof(seq->name) - 2) * 2];
+                       char name_esc_smd[sizeof(smd->name) * 2];
+
+                       BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
+                       BLI_strescape(name_esc_smd, smd->name, sizeof(name_esc_smd));
+                       return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].modifiers[\"%s\"].color_balance",
+                                           name_esc, name_esc_smd);
                }
        }
        else
@@ -895,10 +920,18 @@ static char *rna_SequenceModifier_path(PointerRNA *ptr)
        SequenceModifierData *smd = ptr->data;
        Sequence *seq = sequence_get_by_modifier(ed, smd);
 
-       if (seq && seq->name + 2)
-               return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].modifiers[\"%s\"]", seq->name + 2, smd->name);
-       else
+       if (seq && seq->name + 2) {
+               char name_esc[(sizeof(seq->name) - 2) * 2];
+               char name_esc_smd[sizeof(smd->name) * 2];
+
+               BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
+               BLI_strescape(name_esc_smd, smd->name, sizeof(name_esc_smd));
+               return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].modifiers[\"%s\"]",
+                                   name_esc, name_esc_smd);
+       }
+       else {
                return BLI_strdup("");
+       }
 }
 
 static void rna_SequenceModifier_name_set(PointerRNA *ptr, const char *value)
index 76f005cdd2b3a223819f1e448f3aed1ffce31b84..83a974137e82a2c50f60c96f3a66242ec0767428 100644 (file)
@@ -99,24 +99,30 @@ static char *rna_SmokeDomainSettings_path(PointerRNA *ptr)
 {
        SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
        ModifierData *md = (ModifierData *)settings->smd;
+       char name_esc[sizeof(md->name) * 2];
 
-       return BLI_sprintfN("modifiers[\"%s\"].domain_settings", md->name);
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       return BLI_sprintfN("modifiers[\"%s\"].domain_settings", name_esc);
 }
 
 static char *rna_SmokeFlowSettings_path(PointerRNA *ptr)
 {
        SmokeFlowSettings *settings = (SmokeFlowSettings *)ptr->data;
        ModifierData *md = (ModifierData *)settings->smd;
+       char name_esc[sizeof(md->name) * 2];
 
-       return BLI_sprintfN("modifiers[\"%s\"].flow_settings", md->name);
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       return BLI_sprintfN("modifiers[\"%s\"].flow_settings", name_esc);
 }
 
 static char *rna_SmokeCollSettings_path(PointerRNA *ptr)
 {
        SmokeCollSettings *settings = (SmokeCollSettings *)ptr->data;
        ModifierData *md = (ModifierData *)settings->smd;
+       char name_esc[sizeof(md->name) * 2];
 
-       return BLI_sprintfN("modifiers[\"%s\"].coll_settings", md->name);
+       BLI_strescape(name_esc, md->name, sizeof(name_esc));
+       return BLI_sprintfN("modifiers[\"%s\"].coll_settings", name_esc);
 }
 
 static int rna_SmokeModifier_density_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
index e57d9586a32afb6a39c4f8c06c1c67d735965d61..d01eab053bda450d843d7988c538016e885dd5ed 100644 (file)
@@ -307,10 +307,15 @@ char *rna_TextureSlot_path(PointerRNA *ptr)
        }
        
        /* this is a compromise for the remaining cases... */
-       if (mtex->tex)
-               return BLI_sprintfN("texture_slots[\"%s\"]", mtex->tex->id.name + 2);
-       else
+       if (mtex->tex) {
+               char name_esc[(sizeof(mtex->tex->id.name) - 2) * 2];
+
+               BLI_strescape(name_esc, mtex->tex->id.name + 2, sizeof(name_esc));
+               return BLI_sprintfN("texture_slots[\"%s\"]", name_esc);
+       }
+       else {
                return BLI_strdup("texture_slots[0]");
+       }
 }
 
 static int rna_TextureSlot_name_length(PointerRNA *ptr)
index 6f0478b5eec5829ef17ffd8eff42636d312a94df..d315912eb8461877774b91b223288bc5a2f0903d 100644 (file)
@@ -82,9 +82,10 @@ static void rna_tracking_defaultSettings_searchUpdate(Main *UNUSED(bmain), Scene
 
 static char *rna_trackingTrack_path(PointerRNA *ptr)
 {
-       MovieTrackingTrack *track = (MovieTrackingTrack *) ptr->data;
-
-       return BLI_sprintfN("tracking.tracks[\"%s\"]", track->name);
+       MovieTrackingTrack *track = (MovieTrackingTrack *)ptr->data;
+       char name_esc[sizeof(track->name) * 2];
+       BLI_strescape(name_esc, track->name, sizeof(name_esc));
+       return BLI_sprintfN("tracking.tracks[\"%s\"]", name_esc);
 }
 
 static void rna_trackingTracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)