Skip to contentSkip to conversation

archiver: Escape recipe name in regex

PATCH In review Joshua Watt 1 participant 2 messages Jun 6, 2017 – Jun 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 archiver: Escape recipe name in regex

From: Joshua Watt <[email protected]>

The recipe name needs to be escaped when using it in a regular expression so that and special characters are treated literally

(From OE-Core rev: 53c8cceb744adda1bf899d62071d11b20a5dea98)

---
 meta/classes/archiver.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/archiver.bbclass +2 -2
index 3543ca9..188f8c0 100644
@@ -349,8 +349,8 @@ python do_ar_recipe () {
     bbappend_files = d.getVar('BBINCLUDED', True).split()
     # If recipe name is aa, we need to match files like aa.bbappend and aa_1.1.bbappend
     # Files like aa1.bbappend or aa1_1.1.bbappend must be excluded.
-    bbappend_re = re.compile( r".*/%s_[^/]*\.bbappend$" %pn)
-    bbappend_re1 = re.compile( r".*/%s\.bbappend$" %pn)
+    bbappend_re = re.compile( r".*/%s_[^/]*\.bbappend$" % re.escape(pn))
+    bbappend_re1 = re.compile( r".*/%s\.bbappend$" % re.escape(pn))
     for file in bbappend_files:
         if bbappend_re.match(file) or bbappend_re1.match(file):
             shutil.copy(file, outdir)
Signature · 1 line
2.9.4
#1 lore raw
Quoted 23 lines · Joshua Watt

From: Joshua Watt <[email protected]>

The recipe name needs to be escaped when using it in a regular expression so
that and special characters are treated literally

(From OE-Core rev: 53c8cceb744adda1bf899d62071d11b20a5dea98)

---
 meta/classes/archiver.bbclass | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/archiver.bbclass +0 -0
index 3543ca9..188f8c0 100644
@@ -349,8 +349,8 @@ python do_ar_recipe () {
      bbappend_files = d.getVar('BBINCLUDED', True).split()
      # If recipe name is aa, we need to match files like aa.bbappend

and aa_1.1.bbappend
     # Files like aa1.bbappend or aa1_1.1.bbappend must be excluded.

Quoted 8 lines

-    bbappend_re = re.compile( r".*/%s_[^/]*\.bbappend$" %pn) -    bbappend_re1 = re.compile( r".*/%s\.bbappend$" %pn) +    bbappend_re = re.compile( r".*/%s_[^/]*\.bbappend$" % re.escape(pn))
+    bbappend_re1 = re.compile( r".*/%s\.bbappend$" % re.escape(pn)) for file in bbappend_files:
         if bbappend_re.match(file) or bbappend_re1.match(file):
             shutil.copy(file, outdir)

Ping?