From 4b421550d3c10bb3c11f4be1a4c090d6e96ac910 Mon Sep 17 00:00:00 2001
From: Dave Page <dpage@pgadmin.org>
Date: Wed, 15 May 2019 09:44:57 +0100
Subject: [PATCH] Stop using application/x-javascript as a mime type and use
 the RFC-compliant application/javascript instead. Fixes #4261

---
 docs/en_US/release_notes_4_7.rst                     |  3 ++-
 web/pgadmin/browser/__init__.py                      | 12 ++++++------
 .../browser/server_groups/servers/__init__.py        |  2 +-
 .../foreign_servers/__init__.py                      |  2 +-
 .../foreign_servers/user_mapping/__init__.py         |  2 +-
 .../servers/databases/schemas/domains/__init__.py    |  2 +-
 .../databases/schemas/foreign_tables/__init__.py     |  2 +-
 .../databases/schemas/fts_configurations/__init__.py |  2 +-
 .../databases/schemas/fts_dictionaries/__init__.py   |  2 +-
 .../databases/schemas/fts_templates/__init__.py      |  2 +-
 .../servers/databases/schemas/functions/__init__.py  |  6 +++---
 .../servers/databases/schemas/packages/__init__.py   |  2 +-
 .../databases/schemas/packages/edbfuncs/__init__.py  |  4 ++--
 .../databases/schemas/packages/edbvars/__init__.py   |  2 +-
 .../servers/databases/schemas/sequences/__init__.py  |  2 +-
 .../databases/schemas/tables/constraints/__init__.py |  2 +-
 .../tables/constraints/check_constraint/__init__.py  |  2 +-
 .../constraints/exclusion_constraint/__init__.py     |  2 +-
 .../tables/constraints/foreign_key/__init__.py       |  2 +-
 .../tables/constraints/index_constraint/__init__.py  |  2 +-
 .../databases/schemas/tables/rules/__init__.py       |  2 +-
 .../servers/resource_groups/__init__.py              |  2 +-
 .../server_groups/servers/tablespaces/__init__.py    |  2 +-
 web/pgadmin/browser/utils.py                         |  2 +-
 24 files changed, 33 insertions(+), 32 deletions(-)

#diff --git a/docs/en_US/release_notes_4_7.rst b/docs/en_US/release_notes_4_7.rst
#index d4cfe84a4a..9756e8bc2a 100644
#--- a/docs/en_US/release_notes_4_7.rst
#+++ b/docs/en_US/release_notes_4_7.rst
#@@ -17,4 +17,5 @@ Bug fixes
# | `Bug #4164 <https://redmine.postgresql.org/issues/4164>`_ - Fix file browser path issue which occurs when client is on Windows and server is on Mac/Linux.
# | `Bug #4218 <https://redmine.postgresql.org/issues/4218>`_ - Properly assign dropdownParent in Select2 controls.
# | `Bug #4219 <https://redmine.postgresql.org/issues/4219>`_ - Ensure popper.js is installed when needed.
#-| `Bug #4246 <https://redmine.postgresql.org/issues/4246>`_ - Fixed console error when subnode control is used in panels.
#\ No newline at end of file
#+| `Bug #4246 <https://redmine.postgresql.org/issues/4246>`_ - Fixed console error when subnode control is used in panels.
#+| `Bug #4261 <https://redmine.postgresql.org/issues/4261>`_ - Stop using application/x-javascript as a mime type and use the RFC-compliant application/javascript instead.
#\ No newline at end of file
diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
index b77514e65f..fe2af7dc97 100644
--- a/web/pgadmin/browser/__init__.py
+++ b/web/pgadmin/browser/__init__.py
@@ -623,14 +623,14 @@ def utils():
             pg_libpq_version=pg_libpq_version,
             support_ssh_tunnel=config.SUPPORT_SSH_TUNNEL
         ),
-        200, {'Content-Type': 'application/x-javascript'})
+        200, {'Content-Type': 'application/javascript'})
 
 
 @blueprint.route("/js/endpoints.js")
 def exposed_urls():
     return make_response(
         render_template('browser/js/endpoints.js'),
-        200, {'Content-Type': 'application/x-javascript'}
+        200, {'Content-Type': 'application/javascript'}
     )
 
 
@@ -639,7 +639,7 @@ def exposed_urls():
 def error_js():
     return make_response(
         render_template('browser/js/error.js', _=gettext),
-        200, {'Content-Type': 'application/x-javascript'})
+        200, {'Content-Type': 'application/javascript'})
 
 
 @blueprint.route("/js/node.js")
@@ -659,14 +659,14 @@ def node_js():
                         edbas_help_path=edbas_help_path,
                         _=gettext
                         ),
-        200, {'Content-Type': 'application/x-javascript'})
+        200, {'Content-Type': 'application/javascript'})
 
 
 @blueprint.route("/js/messages.js")
 def messages_js():
     return make_response(
         render_template('browser/js/messages.js', _=gettext),
-        200, {'Content-Type': 'application/x-javascript'})
+        200, {'Content-Type': 'application/javascript'})
 
 
 @blueprint.route("/js/collection.js")
@@ -674,7 +674,7 @@ def messages_js():
 def collection_js():
     return make_response(
         render_template('browser/js/collection.js', _=gettext),
-        200, {'Content-Type': 'application/x-javascript'})
+        200, {'Content-Type': 'application/javascript'})
 
 
 @blueprint.route("/browser.css")
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index de06840336..dd4572b64e 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -930,7 +930,7 @@ def supported_servers(self, **kwargs):
                 "servers/supported_servers.js",
                 server_types=ServerType.types()
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def connect_status(self, gid, sid):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
index 10f919c958..78f7d281af 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
@@ -206,7 +206,7 @@ def module_js(self):
                 "foreign_servers/js/foreign_servers.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
index 626d025012..0ba0ac5004 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
@@ -223,7 +223,7 @@ def module_js(self):
                 "user_mappings/js/user_mappings.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
index c6895eb043..1bc8b65706 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
@@ -255,7 +255,7 @@ def module_js(self):
                 "domains/js/domains.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
index 2d206bff78..8999d2e1fb 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
@@ -328,7 +328,7 @@ def module_js(self):
                 "foreign_tables/js/foreign_tables.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
index df9bb4e46c..7c0a22637c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
@@ -224,7 +224,7 @@ def module_js(self):
                 "fts_configuration/js/fts_configuration.js",
                 _=_
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
index e95d8abd95..5bb9133912 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
@@ -212,7 +212,7 @@ def module_js(self):
                 "fts_dictionary/js/fts_dictionary.js",
                 _=_
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
index 6042562402..ea3a58db06 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
@@ -207,7 +207,7 @@ def module_js(self):
                 "fts_template/js/fts_templates.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
index fda1cf8748..b41ec44d74 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
@@ -313,7 +313,7 @@ def module_js(self):
                 "function/js/functions.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
@@ -1686,7 +1686,7 @@ def module_js(self):
                 "procedure/js/procedures.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
 
@@ -1797,7 +1797,7 @@ def module_js(self):
                 "trigger_function/js/trigger_functions.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
index 89c5ed639f..8e6c463ea8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
@@ -121,7 +121,7 @@ def module_js(self):
                 "package/js/package.js",
                 _=_
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(action=None):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
index a6b0643b95..2860182427 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
@@ -201,7 +201,7 @@ def module_js(self):
                 "edbfunc/js/edbfunc.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
@@ -709,7 +709,7 @@ def module_js(self):
                 "edbproc/js/edbproc.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/__init__.py
index db44b70234..3c4346e182 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/__init__.py
@@ -175,7 +175,7 @@ def module_js(self):
                 "edbvar/js/edbvar.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
index d0b40f075e..96fd0e6dfe 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -126,7 +126,7 @@ def module_js(self):
                 "sequence/js/sequence.js",
                 _=_
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(action=None):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/__init__.py
index b3dd8a0096..7d90195bed 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/__init__.py
@@ -149,5 +149,5 @@ def module_js():
                 for n in ConstraintRegistry.registry
             ]
         ),
-        200, {'Content-Type': 'application/x-javascript'}
+        200, {'Content-Type': 'application/javascript'}
     )
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
index aa422066ad..9437116b33 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
@@ -196,7 +196,7 @@ def module_js(self):
                 "check_constraint/js/check_constraint.js",
                 _=_
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
index e204f5e09d..fbe3a480d6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
@@ -223,7 +223,7 @@ def module_js(self):
                 "exclusion_constraint/js/exclusion_constraint.js",
                 _=_
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
index e2f04afba5..b581fe8349 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
@@ -233,7 +233,7 @@ def module_js(self):
                 "foreign_key/js/foreign_key.js",
                 _=_
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
index dac45a0d0e..d1d36d5207 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
@@ -245,7 +245,7 @@ def module_js(self):
                 node_type=self.node_type,
                 node_label=self.node_label
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
index bdbd4f1cf0..b45ed3ea92 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
@@ -188,7 +188,7 @@ def module_js(self):
                 "rules/js/rules.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/__init__.py b/web/pgadmin/browser/server_groups/servers/resource_groups/__init__.py
index ea0a2ed85b..ea564b91bd 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/__init__.py
@@ -219,7 +219,7 @@ def module_js(self):
                 "resource_groups/js/resource_groups.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
index 46940b4e7e..5317ea712d 100644
--- a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
@@ -105,7 +105,7 @@ def module_js(self):
                 "tablespaces/js/tablespaces.js",
                 _=gettext
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def check_precondition(f):
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index 52b3f51a52..2fe2d9080a 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -298,7 +298,7 @@ def module_js(self, **kwargs):
             flask.render_template(
                 "{0}/js/{0}.js".format(self.node_type)
             ),
-            200, {'Content-Type': 'application/x-javascript'}
+            200, {'Content-Type': 'application/javascript'}
         )
 
     def children(self, *args, **kwargs):
