From 1dbe6c746f9f5b0ddbce22e228835010c000d67b Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Tue, 17 Jan 2017 23:06:15 +0100 Subject: Partially fix opening of librevenge based input formats (cdr/vsd/wpg) on Windows if the filename contains non-ASCII characters The problem is that "RVNGFileStream" uses "fopen()" internally which only supports ANSI filenames on Windows (i.e. a complete fix would require upstream code changes). By using "g_win32_locale_filename_from_utf8()" the problem can be worked around in most cases, though: * the filename is converted to the current codepage (i.e. all 255 characters that are available in the current character encoding are allowed in the filename) * even if the filename contains a character that's not available in the current character encoding it's attempted to use the alternative short (8.3) file name instead Therefore the input operation will only fail in the unlikely case that the filename contains a character not available in the current ANSI code page while at the same time short file names are disabled on the file system (which is not the case in standard configurations). Fixed bugs: - https://launchpad.net/bugs/1656763 - https://launchpad.net/bugs/1656763 (bzr r15421) --- src/extension/internal/wpg-input.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/extension/internal/wpg-input.cpp') diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index 54a14fc72..12457791b 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -81,6 +81,13 @@ namespace Internal { SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { + #ifdef WIN32 + // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows + // therefore attempt to convert uri to the system codepage + // even if this is not possible the alternate short (8.3) file name will be used if available + uri = g_win32_locale_filename_from_utf8(uri); + #endif + RVNGInputStream* input = new RVNGFileStream(uri); #if WITH_LIBWPG03 if (input->isStructured()) { -- cgit v1.2.3 From 9faf941d45ce7d23f5cb0d066bd23346f7e3aedf Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 11 Feb 2017 01:16:53 +0100 Subject: Fix a memory leak introduced in r15421 and r15501 respectively (bzr r15505) --- src/extension/internal/wpg-input.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/extension/internal/wpg-input.cpp') diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index 12457791b..299614c94 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -85,10 +85,13 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows // therefore attempt to convert uri to the system codepage // even if this is not possible the alternate short (8.3) file name will be used if available - uri = g_win32_locale_filename_from_utf8(uri); + gchar * converted_uri = g_win32_locale_filename_from_utf8(uri); + RVNGInputStream* input = new RVNGFileStream(converted_uri); + g_free(converted_uri); + #else + RVNGInputStream* input = new RVNGFileStream(uri); #endif - RVNGInputStream* input = new RVNGFileStream(uri); #if WITH_LIBWPG03 if (input->isStructured()) { RVNGInputStream* olestream = input->getSubStreamByName("PerfectOffice_MAIN"); -- cgit v1.2.3