Skip to content

Fix dataURL() returning NULL for MIME types such as application/octet-stream - #165

Open
samipuro wants to merge 1 commit into
GravityPDF:mainfrom
samipuro:fix/dataurl-mime-type
Open

samipuro wants to merge 1 commit into
GravityPDF:mainfrom
samipuro:fix/dataurl-mime-type

Conversation

@samipuro

@samipuro samipuro commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Pull Request type

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

The dataURL($attr) getter only matches MIME types made of letters and digits, so it returns NULL for the default application/octet-stream that the setter writes, and for types such as image/svg+xml:

$qp = qp('<?xml version="1.0"?><root><item/></root>', 'item');
$qp->dataURL('a', 'hello');  // writes data:application/octet-stream;base64,aGVsbG8=
var_dump($qp->dataURL('a')); // NULL

What is the new behavior?

  • The getter accepts the characters RFC 6838 allows in a type and subtype
  • A value written by dataURL($attr, $data, $mime) with a plain type/subtype MIME type can be read back

Does this introduce a breaking change?

  • Yes
  • No

Other information

Adds DOMQueryTest::testDataURLRoundTripsMimeTypesWithPunctuation and a CHANGELOG entry.

@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.23%. Comparing base (3872ee0) to head (ba29c83).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #165   +/-   ##
=========================================
  Coverage     91.23%   91.23%           
  Complexity     1441     1441           
=========================================
  Files            26       26           
  Lines          3183     3183           
=========================================
  Hits           2904     2904           
  Misses          279      279           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant