Skip to content

Empty path def crashes jspdf #278

@edemaine

Description

@edemaine

Describe the bug
It seems that a <path> with no d argument, inside a <defs>, crashes when <use>d.

What version are you using (exact version of svg2pdf.js and jspdf)?

To Reproduce
Minimal SVG input:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 150">
  <defs>
    <path id="MJX-34-TEX-N-2061" d=""/>
  </defs>
  <use href="#MJX-34-TEX-N-2061" />
</svg>

Playground link

Expected behavior
I would have expected a blank PDF. Chrome has no issues rendering this.

Actual behavior
Exception:
Error in function M.y.hpf.y.__private__.hpf (https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js:86:5369): Invalid argument passed to jsPDF.hpf

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Chrome
  • Version: 119

Additional context
This SVG is admittedly a little silly, but it's automatically generated from MathJax's SVG output. I could filter out dummy symbols like this, but it would be nicer if jspdf didn't crash in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions