[bitbake-devel] [PATCH 5/5] toaster: toastergui Fix invalid char test and implementation

brian avery avery.brian at gmail.com
Fri Feb 19 05:21:52 UTC 2016


From: Michael Wood <michael.g.wood at intel.com>

This test was passing but because the assertion was the wrong way round
and should have expected the first one to pass and second one to fail,
in reality both were failing as the method for checking the invalid char
was incorrect.

Signed-off-by: Michael Wood <michael.g.wood at intel.com>
Signed-off-by: brian avery <avery.brian at gmail.com>
---
 lib/toaster/toastergui/tests.py | 2 +-
 lib/toaster/toastergui/views.py | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/toaster/toastergui/tests.py b/lib/toaster/toastergui/tests.py
index 1b6e78d..4e420ea 100644
--- a/lib/toaster/toastergui/tests.py
+++ b/lib/toaster/toastergui/tests.py
@@ -155,7 +155,7 @@ class ViewTests(TestCase):
         response = self.client.post(reverse('xhr_importlayer'), args)
         data = json.loads(response.content)
         self.assertEqual(response.status_code, 200)
-        self.assertNotEqual(data["error"], "ok")
+        self.assertEqual(data["error"], "ok")
 
         #Test to verify import of a layer successful
         args['name'] = "meta-oe"
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index dfa256e..13489af 100755
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -2185,8 +2185,11 @@ if True:
         layers_added = [];
 
         # Rudimentary check for any possible html tags
-        if "<" in request.POST:
-          return HttpResponse(jsonfilter({"error": "Invalid character <"}), content_type = "application/json")
+        for val in request.POST.values():
+            if "<" in val:
+                return HttpResponse(jsonfilter(
+                    {"error": "Invalid character <"}),
+                    content_type="application/json")
 
         prj = Project.objects.get(pk=request.POST['project_id'])
 
-- 
1.9.1




More information about the bitbake-devel mailing list