1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
From: =?utf-8?q?Ren=C3=A9_Rebe?= <rene@exactcode.de>
Date: Wed, 30 Dec 2015 08:36:20 +0000
Subject: fixed loading (absolute) filenames with colon (was parsed as codec
spec)
Origin: backport, https://svn.exactcode.de/exact-image/trunk@2187
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/exactimage/+bug/1516548
---
codecs/Codecs.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/codecs/Codecs.cc b/codecs/Codecs.cc
index 054548f..eda7691 100644
--- a/codecs/Codecs.cc
+++ b/codecs/Codecs.cc
@@ -54,14 +54,14 @@ std::string ImageCodec::getExtension (const std::string& filename)
std::string ImageCodec::getCodec (std::string& filename)
{
// parse the codec spec, prefixed to the filename, e.g. jpg:, tif:, raw:, ...
- std::string::size_type idx_colon = filename.find (':');
+ std::string::size_type idx_colon = filename.find_first_of(":/");
// unfortunately, Windows has this silly concept of drive "letters",
// just limit the codec spec to anything longer than a single char
#ifdef _WIN32
if (idx_colon && idx_colon < 2)
- idx_colon = filename.find (':', idx_colon + 1);
+ idx_colon = std::string::npos;
#endif
- if (idx_colon && idx_colon != std::string::npos) {
+ if (idx_colon && idx_colon != std::string::npos && filename[idx_colon] != '/') {
std::string codec = filename.substr (0, idx_colon);
filename.erase (0, idx_colon+1);
return codec;
|