From 7ec02f1dc78524b1f9ae5634b9ca63ccf97d2739 Mon Sep 17 00:00:00 2001 From: Jan Beran Date: Apr 30 2021 08:46:14 +0000 Subject: flatpak_generator: Fix regex Original regex just matched multiline C-like comments and did mistakes when sometimes matched filesystem wildcard "*" (eg. in /usr/lib/*.so) as a start of the comment. New regex forbids nested comments (which are forbidden in C as well) which also solves the problem above (no trailing */ found -> no match). There still are some very unprobable situations when this (as well as the old one) regex fails (like /usr/*/app-version*/) though. --- diff --git a/_fedmod/flatpak_generator.py b/_fedmod/flatpak_generator.py index dd79a1b..d3c9551 100644 --- a/_fedmod/flatpak_generator.py +++ b/_fedmod/flatpak_generator.py @@ -116,7 +116,10 @@ def _load_flathub_manifest(search_term): else: # flatpak-builder supports non-standard comments in the manifest, strip # them out. (Ignore the possibility of C comments embedded in strings.) - no_comments = re.sub(r'/\*.*?\*/', '', response.text, flags=re.DOTALL) + # + # Regex explanation: matches /**/ (multiline) + # DOES NOT contains "/*" substring + no_comments = re.sub(r'/\*((?!/\*).)*?\*/', '', response.text, flags=re.DOTALL) return json.loads(no_comments)