Project

Profile

Help

Bug #4191

closed

Saxon-JS error on null Content-Type

Added by David Cramer almost 5 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
IXSL extensions
Sprint/Milestone:
-
Start date:
2019-04-07
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
1.0, Trunk
Fix Committed on JS Branch:
1.0, Trunk
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

In my UI, I poll the server and refresh content on the page that's changed. I added support for the etag[1] header and ran across a Saxon-JS bug. When I sent an If-None-Match header and the resource is unchanged, the server sends back a "304 Not Modified" and no Content-Type, causing the line in Saxon-JS "var typeParts = respContentType.split(/;/);" to fail with "TypeError: null is not an object (evaluating 'respContentType.split')". I wrapped it in a try/catch as a workaround. Note I had already modified "var part2" to avoid a different error: https://saxonica.plan.io/boards/5/topics/7423

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

dcramer@anatine ~/git-repos/spec-service (updateTitleAndAuthorAuthorUI *)
$ git diff api/app/src/main/webapp/author/resources/Saxon-JS/SaxonJS.js
diff --git a/api/app/src/main/webapp/author/resources/Saxon-JS/SaxonJS.js b/api/app/src/main/webapp/author/resources/Saxon-JS/SaxonJS.js
index f540b4b..f567d87 100644
--- a/api/app/src/main/webapp/author/resources/Saxon-JS/SaxonJS.js
+++ b/api/app/src/main/webapp/author/resources/Saxon-JS/SaxonJS.js
@@ -368,8 +368,13 @@ var BrowserPlatform = (function () {
                 if (!request["status-only"]) {
                     var respContentType = http.getResponseHeader('Content-Type');
                     // get part of string before ';'
-                    var typeParts = respContentType.split(/;/);
-                    var mediaType = typeParts[0];
+                    // DWC: Adding Try/Catch in case there's no ; in the respConentType
+                    try{
+                        var typeParts = respContentType.split(/;/);
+                        var mediaType = typeParts[0];
+                        } catch(e) {
+                            var mediaType = respContentType;
+                        }
                     var part2 = ''; //typeParts[1].trim(); // will this work if 'Content-Type' string only contains media type?
                     // part2 may be 'boundary=...' (if multipart), or encoding 'charset=...'
                     // TODO use part2
Actions #1

Updated by Michael Kay almost 5 years ago

  • Assignee set to Debbie Lockett
  • Priority changed from Low to Normal
Actions #2

Updated by Debbie Lockett almost 5 years ago

Thanks for reporting this. It has been added to the list of things to fix in makeHttpRequest!

Actions #3

Updated by Debbie Lockett about 4 years ago

  • Status changed from New to In Progress
  • Applies to JS Branch 1.0, Trunk added

Repro: supply status code 304 in httpStatusTest.

Actions #4

Updated by Debbie Lockett about 4 years ago

  • Status changed from In Progress to Resolved
  • Fix Committed on JS Branch 1.0, Trunk added

Fix committed: let respContentType default to an empty string if the response Content-Type is null, i.e.:

var respContentType = http.getResponseHeader('Content-Type') || '';

Committed on Saxon-JS 1.x and 2 branches.

Actions #5

Updated by Debbie Lockett over 3 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 2.0
Actions #6

Updated by Debbie Lockett over 3 years ago

  • Category set to IXSL extensions

Please register to edit this issue

Also available in: Atom PDF Tracking page