From f748b4760d0f8247001c0b46e9eaf02b379bc3c4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 25 Jul 2011 16:53:18 +0200 Subject: * apt-pkg/contrib/cdromutl.cc: - fix escape problem when looking for the mounted devices --- apt-pkg/contrib/cdromutl.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib/cdromutl.cc') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 821e6d688..551efa7d9 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -258,7 +258,13 @@ string FindMountPointForDevice(const char *devnode) if(TokSplitString(' ', buf, out, 10)) { fclose(f); - return string(out[1]); + // unescape \040 and return the path + size_t pos; + string mount_point = out[1]; + static const char *needle = "\\040"; + while ((pos = mount_point.find(needle)) != string::npos) + mount_point.replace(pos, strlen(needle), " "); + return mount_point; } } } -- cgit v1.2.3 From a513ace2d2e3b71d607257990893199c6105b072 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jul 2011 10:49:28 +0200 Subject: * apt-pkg/contrib/strutl.{h,cc}, test/libapt/strutil_test.cc: - add new DeEscapeString() similar to DeQuoteQuotedWord but unescape charackter escapes like \0XXX and \xXX (plus add test) --- apt-pkg/contrib/cdromutl.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'apt-pkg/contrib/cdromutl.cc') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 551efa7d9..e25caf1a5 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -258,13 +258,9 @@ string FindMountPointForDevice(const char *devnode) if(TokSplitString(' ', buf, out, 10)) { fclose(f); - // unescape \040 and return the path - size_t pos; + // unescape the \0XXX chars in the path string mount_point = out[1]; - static const char *needle = "\\040"; - while ((pos = mount_point.find(needle)) != string::npos) - mount_point.replace(pos, strlen(needle), " "); - return mount_point; + return DeEscapeString(mount_point); } } } -- cgit v1.2.3