Masterminds / Masterminds/html5-php

ext-mbstring should be required

Open
#203 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
1.8k
Forks
122
PR merge metrics
No merged PRs in 30d

Description

Here's why:

  1. Masterminds\HTML5\Parser\CharacterReference::lookupDecimal() uses mb_decode_numericentity() unconditionally.
  2. Looking at Masterminds\HTML5\Parser\UTF8Utils::convertToUTF8() either iconv or mbstring must be available (if the input encoding is not 'auto').

This would allow to:

  1. Get rid of iconv() use. In my experience mbstring is really a better solution.
  2. Remove use of utf8_decode() which is not really valid and not needed when mbstring is available.
  3. Get rid of the fallback code.

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 by reviewing Masterminds\HTML5\Parser\CharacterReference::lookupDecimal() and Masterminds\HTML5\Parser\UTF8Utils::convertToUTF8(), focusing on their unconditional mbstring use and iconv/utf8_decode fallbacks. Done means mbstring is required, iconv and utf8_decode fallback code are removed, and the parser continues to handle non-auto input encodings correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
web-dev
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 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.