Project

Profile

Help

Bug #6506

closed

Passing a buffer as the sourceText to SaxonJS.transform gives a nasty error

Added by Norm Tovey-Walsh 2 months ago. Updated 8 days ago.

Status:
Resolved
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2024-08-13
Due date:
% Done:

50%

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

Description

You're supposed to pass a string, but if you pass a buffer it crashes out with a really nasty error message. We should accept a buffer and/or test that it's a string and give a reasonable error message.

Actions #1

Updated by Norm Tovey-Walsh 2 months ago

  • Status changed from New to Resolved
  • Applies to JS Branch 2, Trunk added
  • Fix Committed on JS Branch 2, Trunk added

If a user passes a Buffer (as one might get from fs.read...) as a text input, convert the buffer to a string.

(I think this is less likely in the browser where there's no obvious file I/O mechanism to get a buffer, so I haven't tried to address it in the browser platform.)

Actions #2

Updated by Debbie Lockett 10 days ago

The fix cherry-picked and pushed to the saxonjs2 branch was broken. It relies on new code only on the main branch (i.e. the decodeBuffer function in NodeJSPlatform.js) which is part of extensive changes in the area.

For SaxonJS 2, I think we should just improve the error message if the sourceText option for SaxonJS.transform is not a string.

I have committed changes in the code and updated the test (nodejs/iss6506) on the saxonjs2 branch accordingly.

Actions #3

Updated by Debbie Lockett 8 days ago

  • % Done changed from 0 to 50

Error message fix applied in the SaxonJS 2.7 maintenance release.

Full bug fix will be applied in SaxonJS 3.0.

Please register to edit this issue

Also available in: Atom PDF Tracking page