This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit d35afd9f104bb84957dd8b46f24bdd47add61bb4
Author: zhangyifan27 <[email protected]>
AuthorDate: Tue Aug 13 16:12:44 2024 +0800

    IMPALA-13196 (part2): fix some urls in template files
    
    This patch qualified some urls in template files.
    
    Testing:
      - Manully checked importing json profiles worked correctly with the
    fix.
      - Added new regex checks to test_knox_compatibility.
    
    Change-Id: If53947c3b8429840990b361a936ba31e1df21522
    Reviewed-on: http://gerrit.cloudera.org:8080/21574
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 tests/webserver/test_web_pages.py | 10 ++++++++--
 www/queries.tmpl                  |  6 +++---
 www/query_plan_text.tmpl          |  3 ++-
 www/query_profile.tmpl            |  3 ++-
 www/query_stmt.tmpl               |  3 ++-
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/tests/webserver/test_web_pages.py 
b/tests/webserver/test_web_pages.py
index 5e4a73118..cf260e452 100644
--- a/tests/webserver/test_web_pages.py
+++ b/tests/webserver/test_web_pages.py
@@ -894,8 +894,14 @@ class TestWebPage(ImpalaTestSuite):
     javascript_regex = "open\(['\"]GET['\"], (?!make_url)"
     # Matches urls in json parameters passed to DataTables.
     datatables_regex = "url: ['\"](?!make_url)"
-    regex = "(%s)|(%s)|(%s)|(%s)|(%s)" % \
-        (href_regex, script_regex, form_regex, javascript_regex, 
datatables_regex)
+    # Matches all references of paths that contain '/www/' but are not fully 
qualified.
+    path_regex = r"((?<!{{ __common__.host-url }})(?<!make_url\(\")/www/.*)"
+    # Matches all links with an 'href' attribute that doesn't start with 
'URL', or '`$',
+    # or '`{{ __common__.host-url }}'.
+    link_regex = r"(.*link.*\.href[\s]=[\s](?!(`{{ __common__.host-url 
}})|(`\$)|URL))"
+    regex = "(%s)|(%s)|(%s)|(%s)|(%s)|(%s)|(%s)" % \
+        (href_regex, script_regex, form_regex, javascript_regex, 
datatables_regex,
+         path_regex, link_regex)
     results = grep_dir(os.path.join(os.environ['IMPALA_HOME'], "www"), regex, 
".*\.tmpl")
     assert len(results) == 0, \
         "All links on the webui must include the webserver host: %s" % results
diff --git a/www/queries.tmpl b/www/queries.tmpl
index 3a76aa37c..d5085bb6a 100644
--- a/www/queries.tmpl
+++ b/www/queries.tmpl
@@ -283,8 +283,8 @@ command line parameter.</p>
   var dbOpenReq = indexedDB.open("imported_queries");
   var db;
 
-  const profileParseWorker = new Worker("{{ __common__.host-url }}"
-      + "/www/scripts/queries/profileParseWorker.js");
+  const profileParseWorker = new Worker(
+      "{{ __common__.host-url }}/www/scripts/queries/profileParseWorker.js");
   var query_processor_start_time, raw_total_size, compressed_total_size, 
upload_count;
 
   function insertRowVal(row, val) {
@@ -394,7 +394,7 @@ command line parameter.</p>
         var query = cursor.value;
         var row = imported_queries_table.insertRow();
         var query_link = document.createElement("a");
-        query_link.href = `/query_timeline?query_id=${query.id}&imported=true`;
+        query_link.href = `{{ __common__.host-url 
}}/query_timeline?query_id=${query.id}&imported=true`;
         query_link.innerHTML = query.id;
         insertRowVal(row, query_link.outerHTML);
         insertRowVal(row, query.user);
diff --git a/www/query_plan_text.tmpl b/www/query_plan_text.tmpl
index dc101ba1a..57b780aca 100644
--- a/www/query_plan_text.tmpl
+++ b/www/query_plan_text.tmpl
@@ -26,7 +26,8 @@ under the License.
 <script type="module">
 $("#plan-text-tab").addClass("active");
 
-import {inflateParseJSON} from "./www/scripts/compression_util.js";
+import {inflateParseJSON}
+    from "{{ __common__.host-url }}/www/scripts/compression_util.js";
 
 var dbOpenReq = indexedDB.open("imported_queries");
 var db;
diff --git a/www/query_profile.tmpl b/www/query_profile.tmpl
index 8cc531595..5fce17e62 100644
--- a/www/query_profile.tmpl
+++ b/www/query_profile.tmpl
@@ -46,7 +46,8 @@ under the License.
 <script type="module">
 $("#profile-tab").addClass("active");
 
-import {inflateParseJSON} from "./www/scripts/compression_util.js";
+import {inflateParseJSON}
+    from "{{ __common__.host-url }}/www/scripts/compression_util.js";
 
 var dbOpenReq = indexedDB.open("imported_queries");
 var db;
diff --git a/www/query_stmt.tmpl b/www/query_stmt.tmpl
index 4e00aa30e..c2e08611c 100644
--- a/www/query_stmt.tmpl
+++ b/www/query_stmt.tmpl
@@ -36,7 +36,8 @@ under the License.
 <script type="module">
 $("#stmt-tab").addClass("active");
 
-import {inflateParseJSON} from "./www/scripts/compression_util.js";
+import {inflateParseJSON}
+    from "{{ __common__.host-url }}/www/scripts/compression_util.js";
 
 var dbOpenReq = indexedDB.open("imported_queries");
 var db;

Reply via email to