ezyang / ezyang/htmlpurifier

[PHP7.2] "A non well formed numeric value encountered" in length conversion

Open
#187 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.4k
Forks
361
Avg merge
3d 41m
Merged PRs (30d)
2

Description

Hey,

we're using the purifier to clean up HTML mails before display. We recently upgraded to PHP 7.2 and now got a mail (from Outlook 😩 ) which runs into a notice which breaks our app.

The error is thrown in vendor/ezyang/htmlpurifier/library/HTMLPurifier/Length.php while comparing 2 lengths:

HTMLPurifier_Length {#7557 ▼
  #n: ".5208"
  #unit: "in"
  #isValid: true
}

and

HTMLPurifier_Length {#7645 ▼
  #n: "1200"
  #unit: "px"
  #isValid: null
}

At the end he tries to substract ".5208" - "0,0000" (the latter with a comma) and that throws the notice. I've dug into the to UnitConverter, but the comma is all the time around. We don't have bcmath installed. After installing that he correctly converts the 1200px into "12.5" and doesn't explode.

Cheers
Matthias

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 vendor/ezyang/htmlpurifier/library/HTMLPurifier/Length.php, where the comparison triggers the notice, and trace the referenced UnitConverter conversion for .5208in and 1200px without bcmath. Reproduce the PHP 7.2 case, then verify that length comparison no longer emits the malformed numeric value notice and that the conversion produces a usable numeric result.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.