Fix #105395: Handle quoted paths better in the OBJ importer #105478

Merged
Jesse Yurkovich merged 1 commits from deadpin/blender:fix105395-objquote into blender-v3.5-release 2023-03-06 06:29:51 +01:00

1 Commits

Author SHA1 Message Date
Jesse Yurkovich 2653762f1b WIP: Fix #105395: Handle quoted paths better in the OBJ importer
If the texture image path in the MTL is a "quoted" absolute path, the importer will fail to find the
file. It was only attempting to un-quote the path for the relative case. Now we attempt to un-quote
in both all cases.

----
Before
```
Cannot load image file: 'T:\New folder\"T:/New Folder/Testure 1/texture 2/texture 3/texture 4/pavement_03_1k.blend/textures/pavement_03_diff_1k.jpg"'
Cannot load image file: '"T:/New Folder/Testure 1/texture 2/texture 3/texture 4/pavement_03_1k.blend/textures/pavement_03_diff_1k.jpg"'
Cannot load image file: 'T:\New folder\T:/New Folder/Testure 1/texture 2/texture 3/texture 4/pavement_03_1k.blend/textures/pavement_03_diff_1k.jpg'
Cannot load image file: 'T:\New folder\T:/New Folder/Testure 1/texture 2/texture 3/texture 4/pavement 03 1k.blend/textures/pavement 03 diff 1k.jpg'
Cannot load image file: 'T:\New folder\pavement_03_diff_1k.jpg"'
OBJ import of 'daz cube text 4.obj' took 24.5 ms
```

After
```
Cannot load image file: 'T:\New folder\T:/New Folder/Testure 1/texture 2/texture 3/texture 4/pavement_03_1k.blend/textures/pavement_03_diff_1k.jpg'
Loaded image from: 'T:/New Folder/Testure 1/texture 2/texture 3/texture 4/pavement_03_1k.blend/textures/pavement_03_diff_1k.jpg'
OBJ import of 'daz cube text 4.obj' took 3.2 ms
```

Question:
Linux/Mac technically allows folder/file names containing literal `"` quotes. The legacy exporter will write out those quotes
but the legacy importer will not import them correctly.

If a Linux/Mac user zips up such quoted files, as would typically happen when packaging the .obj and accompanying files for distribution, when they are unpacked on Windows the literal `"` is replaced with `_`... (just learned this today!)

We could maybe attempt that replacement as well, like we do spaces.

Thoughts on how best to proceed here? We can certainly try more combinations but we're firing in the dark really.
2023-03-05 18:00:03 -08:00