Package: highlight Version: 2.16-1 Severity: normal Tags: upstream patch -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
getFileSuffix returns all the part of the path passed in as argument after the last dot, without considering whether a path-separator is inside it. This leads to incorrect suffix recognition when the file does not have a suffix, but the path leading to it has a dot, such as for example: ../some-file (returns ./some-file) /path-with.inside/another-file (returns .inside/another-file) The attached patch [1] fixes that on version's 3.7-2 git repository. The attached patch [2] resolves this issue on version 2.16-1 (tested building, installing and running a modified local version). regards George Zarkadas References: [1] Version 3.7-2 patch: 0001-Search-for-file-suffix-only-in-filename-s-basename.patch [2] version 2-16-1 patch: 0001-Fix-false-suffix-recognition-of-filenames-with-a-dot.patch - -- System Information: Debian Release: 6.0.4 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'proposed-updates'), (500, 'stable'), (450, 'testing-proposed-updates'), (450, 'testing'), (400, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores) Locale: LANG=el_GR.utf8, LC_CTYPE=el_GR.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages highlight depends on: ii highlight-common 2.16-1 source code to formatted text conv ii libc6 2.11.3-3 Embedded GNU C Library: Shared lib ii libgcc1 1:4.4.5-8 GCC support library ii libstdc++6 4.6.2-12 GNU Standard C++ Library v3 highlight recommends no packages. highlight suggests no packages. - -- no debconf information -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJPRtHbAAoJEJWXIVmJ5BwWmrUH/jvZPPxBYaCsRhQLi+Cf/p/G MKalbK74WzPdey1poMWpMKknQViZJDZui0L+91poq+VX0RdyIM+mNnTBP1EeOEUD smYSae0pcLMvkn5Fq8zLTCAIAidRl/87gK9p14hSEIVcNPDD9M5mvVPi/idm/x5N SS/XGG/iEVs82oSFIQQp7CUj9w4yMnqAJjiFbkvqxxUw48A6C7COLyCw5d1Qb567 S2O7b1Kj9TLvmq4FwlQlR5paeKV/t/oAYfQ8DDSvqLngtLWUmG9uHwQfWbiiO+/r K+0PtuWSYRWEqnkY/WNzN2BvHA5TFd0ePH8Nqqd/CBHUH7ymmSh6vjDGOHDl8M4= =RYfu -----END PGP SIGNATURE-----
>From 18733cfaa05bbd9956ced1333c20f95f0d2cff0d Mon Sep 17 00:00:00 2001 From: "Georgios M. Zarkadas" <g...@member.fsf.org> Date: Fri, 24 Feb 2012 01:22:31 +0200 Subject: [PATCH] Search for file suffix only in filename's basename. Make the HLCmdLineApp::getFileSuffix member function to return a non-empty file suffix only if the dot is found within the basename of the path that is supplied as an argument. This stops false positives when filenames without a suffix, but with dots inside the path name (such as ../file or have.between/file) are given. --- src/cli/main.cpp | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/cli/main.cpp b/src/cli/main.cpp index 10751f8..cfa9c1f 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -227,7 +227,12 @@ void HLCmdLineApp::printConfigInfo ( const string& configFile ) string HLCmdLineApp::getFileSuffix ( const string &fileName ) { size_t ptPos=fileName.rfind ( "." ); - return ( ptPos == string::npos ) ? "" : fileName.substr ( ptPos+1, fileName.length() ); + size_t psPos = fileName.rfind ( Platform::pathSeparator ); + + if ( ptPos > psPos && ptPos != string::npos ) + return fileName.substr ( ptPos+1, fileName.length() ); + else + return ""; } bool HLCmdLineApp::loadFileTypeConfig ( const string& name, StringMap* extMap, StringMap* shebangMap ) -- 1.7.9
>From a38680a7dd2a3ba97369df9ad988c028b35c07fe Mon Sep 17 00:00:00 2001 From: "Georgios M. Zarkadas" <g...@member.fsf.org> Date: Thu, 23 Feb 2012 01:42:48 +0200 Subject: [PATCH 1/2] Fix false suffix recognition of filenames with a dot outside the basename. --- debian/patches/fix-get-file-suffix | 28 ++++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 29 insertions(+), 0 deletions(-) create mode 100644 debian/patches/fix-get-file-suffix diff --git a/debian/patches/fix-get-file-suffix b/debian/patches/fix-get-file-suffix new file mode 100644 index 0000000..9bedd3d --- /dev/null +++ b/debian/patches/fix-get-file-suffix @@ -0,0 +1,28 @@ +Description: Search for file suffix only in filename's basename. + Make the HLCmdLineApp::getFileSuffix member function to return a non-empty + file suffix only if the dot is found within the basename of the path that + is supplied as an argument. + . + This stops false positives when filenames without a suffix, but with dots + inside the path name (such as ../file or have.between/file) are given. +Author: Georgios M. Zarkadas <g...@member.fsf.org> +Last-Update: 2012-02-23 + +--- a/src/cli/main.cpp ++++ b/src/cli/main.cpp +@@ -205,8 +205,13 @@ + + string HLCmdLineApp::getFileSuffix ( const string &fileName ) + { +- size_t ptPos=fileName.rfind ( "." ); +- return ( ptPos == string::npos ) ? "" : fileName.substr ( ptPos+1, fileName.length() ); ++ size_t ptPos = fileName.rfind ( "." ); ++ size_t psPos = fileName.rfind ( Platform::pathSeparator ); ++ ++ if ( ptPos > psPos && ptPos != string::npos ) ++ return fileName.substr ( ptPos+1, fileName.length() ); ++ else ++ return ""; + } + + bool HLCmdLineApp::loadFileTypeConfig ( const string& name, StringMap* extMap, StringMap* shebangMap ) diff --git a/debian/patches/series b/debian/patches/series index bac224e..7528b29 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,3 @@ fix-shebang-match fix-shebang-regexes +fix-get-file-suffix -- 1.7.9