瀏覽代碼

HUE-5340 [search] Escape Solr field that have XSS injection (like <script>alert(1234)</script>)

Romain Rigaux 9 年之前
父節點
當前提交
a3c5943
共有 2 個文件被更改,包括 6 次插入6 次删除
  1. 2 2
      apps/search/src/search/models.py
  2. 4 4
      apps/search/src/search/tests.py

+ 2 - 2
apps/search/src/search/models.py

@@ -560,7 +560,7 @@ class Collection2(object):
           <div class="span12">%s</div>
         </div>
         <br/>
-      </div>""" % ' '.join(['{{%s}}' % field['name'] for field in fields]),
+      </div>""" % ' '.join(['{{%s}}' % escape(field['name']) for field in fields]),
       "isGridLayout": True,
       "showFieldList": True,
       "showGrid": True,
@@ -599,7 +599,7 @@ class Collection2(object):
   @classmethod
   def _make_field(cls, field, attributes):
     return {
-        'name': str(field),
+        'name': str(escape(field)),
         'type': str(attributes.get('type', '')),
         'isId': attributes.get('required') and attributes.get('uniqueKey'),
         'isDynamic': 'dynamicBase' in attributes

File diff suppressed because it is too large
+ 4 - 4
apps/search/src/search/tests.py


Some files were not shown because too many files changed in this diff