diff options
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 6 | ||||
-rw-r--r-- | source/blender/collada/collada_utils.cpp | 17 | ||||
-rw-r--r-- | source/blender/collada/collada_utils.h | 3 |
3 files changed, 24 insertions, 2 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 835812fddbb..a234d85bc6f 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -131,7 +131,8 @@ bool DocumentImporter::import() // deselect all to select new objects BKE_scene_base_deselect_all(CTX_data_scene(mContext)); - if (!root.loadDocument(mFilename)) { + const std::string encodedFilename = bc_url_encode(mFilename); + if (!root.loadDocument(encodedFilename)) { fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 1st pass\n"); return false; } @@ -146,7 +147,7 @@ bool DocumentImporter::import() COLLADASaxFWL::Loader loader2; COLLADAFW::Root root2(&loader2, this); - if (!root2.loadDocument(mFilename)) { + if (!root2.loadDocument(encodedFilename)) { fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 2nd pass\n"); return false; } @@ -1235,3 +1236,4 @@ bool DocumentImporter::is_armature(COLLADAFW::Node *node){ return false; } + diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 9fdca048177..27af5c0aba2 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -286,3 +286,20 @@ int bc_get_active_UVLayer(Object *ob) Mesh *me = (Mesh *)ob->data; return CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); } + +std::string bc_url_encode(std::string data) { + /* XXX We probably do not need to do a full encoding. + But in case that is necessary,then it can be added here. + */ + return bc_replace_string(data,"#", "%23"); +} + +std::string bc_replace_string(std::string data, const std::string& pattern, + const std::string& replacement) { + size_t pos = 0; + while((pos = data.find(pattern, pos)) != std::string::npos) { + data.replace(pos, pattern.length(), replacement); + pos += replacement.length(); + } + return data; +}
\ No newline at end of file diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index b8990c3fcdd..90282d9d28f 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -77,4 +77,7 @@ extern void bc_bubble_sort_by_Object_name(LinkNode *export_set); extern bool bc_is_root_bone(Bone *aBone, bool deform_bones_only); extern int bc_get_active_UVLayer(Object *ob); +extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement); +extern std::string bc_url_encode(std::string data); + #endif |