Преглед на файлове

HUE-3594 [fb] Smarter DOM based XSS filter on hashes

Enrico Berti преди 9 години
родител
ревизия
3b7c18c
променени са 1 файла, в които са добавени 8 реда и са изтрити 2 реда
  1. 8 2
      apps/filebrowser/src/filebrowser/templates/listdir_components.mako

+ 8 - 2
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1917,7 +1917,10 @@ from django.utils.translation import ugettext as _
 
       if (location.hash != null && location.hash.length > 1) {
         var targetPath = "";
-        var hash = window.location.hash.substring(1).replace(/(<([^>]+)>)/ig, "");
+        var hash = window.location.hash.substring(1);
+        if (hash.search(/(<([^>]+)>)/ig) > -1) {
+          hash = encodeURI(hash);
+        }
         if (hash != null && hash != "") {
           targetPath = "${url('filebrowser.views.view', path='')}";
           if (hash.indexOf("!!") != 0) {
@@ -1993,7 +1996,10 @@ from django.utils.translation import ugettext as _
 
       $(window).bind("hashchange", function () {
         var targetPath = "";
-        var hash = window.location.hash.substring(1).replace(/(<([^>]+)>)/ig, "");
+        var hash = window.location.hash.substring(1);
+        if (hash.search(/(<([^>]+)>)/ig) > -1) {
+          hash = encodeURI(hash);
+        }
 
         if (hash != null && hash != "") {
           addPathToHistory(hash);