Comment 24 for bug 2022915

Revision history for this message
nikhil kshirsagar (nkshirsagar) wrote :

Note - The fix for https://bugs.launchpad.net/ubuntu/+source/sosreport/+bug/2024547 has been built on top of 4.5.4 upstream for this release. The patch is named d/p/0002-regex-flags.patch, pasted below for reference,

Description: Fix do_file_private_sub() bug related to regex flags
Origin: upstream
Bug: https://github.com/sosreport/sos/issues/3261
Applied-Upstream: https://github.com/sosreport/sos/pull/3263
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: sos-4.5.4/sos/report/plugins/__init__.py
===================================================================
--- sos-4.5.4.orig/sos/report/plugins/__init__.py
+++ sos-4.5.4/sos/report/plugins/__init__.py
@@ -1274,7 +1274,12 @@ class Plugin():
         """
         try:
             path = self._get_dest_for_srcpath(srcpath)
- pattern = regexp.pattern if hasattr(regexp, "pattern") else regexp
+ if hasattr(regexp, "pattern"):
+ pattern = regexp.pattern
+ flags = regexp.flags | re.IGNORECASE
+ else:
+ pattern = regexp
+ flags = re.IGNORECASE
             self._log_debug("substituting scrpath '%s'" % srcpath)
             self._log_debug("substituting '%s' for '%s' in '%s'"
                             % (subst, pattern, path))
@@ -1284,8 +1289,8 @@ class Plugin():
             content = readable.read()
             if not isinstance(content, str):
                 content = content.decode('utf8', 'ignore')
- result, replacements = re.subn(regexp, subst, content,
- flags=re.IGNORECASE)
+ result, replacements = re.subn(pattern, subst, content,
+ flags=flags)
             if replacements:
                 self.archive.add_string(result, srcpath)
             else: