modesty / modesty/pdf2json

URIError: URI malformed exception possible (uncaught)

Open
#103 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.2k
Forks
394
Avg merge
3d 5h
Merged PRs (30d)
7

Description

node_modules/pdf3json/lib/pdffont.js:305
        var retVal = encodeURIComponent(str);
                     ^

URIError: URI malformed
    at encodeURIComponent (<anonymous>)
    at cls.flash_encode (/Users/rngadam/coderbunker/prj/EIC/src/eic-cms/eic-cms-cli/node_modules/pdf3json/lib/pdffont.js:305:22)
    at cls.processText (/Users/rngadam/coderbunker/prj/EIC/src/eic-cms/eic-cms-cli/node_modules/pdf3json/lib/pdffont.js:283:25)
    at CanvasRenderingContext2D_.contextPrototype.fillText (/Users/rngadam/coderbunker/prj/EIC/src/eic-cms/eic-cms-cli/node_modules/pdf3json/lib/pdfcanvas.js:204:26)
    at CanvasGraphics_showText [as showText] (eval at <anonymous> (/Users/rngadam/coderbunker/prj/EIC/src/eic-cms/eic-cms-cli/node_modules/pdf3json/lib/pdf.js:60:1), <anonymous>:41251:25)
    at CanvasGraphics_showSpacedText [as showSpacedText] (eval at <anonymous> (/Users/rngadam/coderbunker/prj/EIC/src/eic-cms/eic-cms-cli/node_modules/pdf3json/lib/pdf.js:60:1), <anonymous>:41346:41)
    at CanvasGraphics_executeOperatorList [as executeOperatorList] (eval at <anonymous> (/Users/rngadam/coderbunker/prj/EIC/src/eic-cms/eic-cms-cli/node_modules/pdf3json/lib/pdf.js:60:1), <anonymous>:40560:27)
    at InternalRenderTask__next [as _next] (eval at <anonymous> (/Users/rngadam/coderbunker/prj/EIC/src/eic-cms/eic-cms-cli/node_modules/pdf3json/lib/pdf.js:60:1), <anonymous>:43553:39)
    at InternalRenderTask__continue [as _continue] (eval at <anonymous> (/Users/rngadam/coderbunker/prj/EIC/src/eic-cms/eic-cms-cli/node_modules/pdf3json/lib/pdf.js:60:1), <anonymous>:43545:14)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

Note that an URIError will be thrown if one attempts to encode a surrogate which is not part of a high-low pair

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in node_modules/pdf3json/lib/pdffont.js at flash_encode around line 305, then follow its callers in processText and pdfcanvas.js. Reproduce the malformed-URI path described in the stack trace and verify that malformed text no longer causes an uncaught URIError during PDF processing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.