Skip to contentSkip to conversation

Fix broken regex for recipes with names containing + signs

PATCH New Paul Eggleton 1 participant 1 message Oct 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix broken regex for recipes with names containing + signs

In order to show bbappends on the recipe detail page we are doing a regex query to find any whose names match up with the recipe. In the layer index instance at layers.openembedded.org viewing the recipe detail page for any recipe whose name contains ++ (e.g. libsigc++-2.0 in meta-oe) results in an invalid regex and causes a database error. Escape any + signs in the name used within the regex in order to fix this.

(I wasn't actually able to reproduce this on my own setup despite also using MariaDB, but I did find that the unescaped query was not correctly matching records so it needed to be fixed anyway.)

---
 layerindex/views.py | 1 +
 1 file changed, 1 insertion(+)
layerindex/views.py +1 -0
index 4eed0cef..5ac7ffab 100644
@@ -869,6 +869,7 @@ class RecipeDetailView(DetailView):
         if recipe:
             verappendprefix = recipe.filename.split('.bb')[0]
             appendprefix = verappendprefix.split('_')[0]
+            appendprefix = appendprefix.replace('+', r'\+')
             #context['verappends'] = BBAppend.objects.filter(layerbranch__branch=recipe.layerbranch.branch).filter(filename='%s.bbappend' % verappendprefix)
             context['appends'] = BBAppend.objects.filter(layerbranch__branch=recipe.layerbranch.branch).filter(filename__regex=r'^%s(_[^_]*)?\.bbappend' % appendprefix)
             verappends = []
Signature · 1 line
2.17.1