ezyang / ezyang/htmlpurifier

Unreachable switch case in PH5P lexer

Open
#209 0 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

https://github.com/ezyang/htmlpurifier/blob/master/library/HTMLPurifier/Lexer/PH5P.php#L1877-L1912

In the switch statement in mainPhase(), both IN_BODY and END_PHASE are cases.

self::IN_BODY is 3.
self::END_PHASE is also 3. Because self::IN_BODY is first, it is checked first, so the code in case self::END_PHASE is unreachable.

This was detected via static analysis (and the only issue of its type in this project) - I'm not sure what the impact is. Maybe the latter one shouldn't be there, but I'm not sure (I don't see the other PHASE constants)

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 library/HTMLPurifier/Lexer/PH5P.php around lines 1877-1912 and trace mainPhase() alongside the PHASE constants, especially IN_BODY and END_PHASE. Determine the intended handling for the duplicate-valued cases and verify that the unreachable branch is resolved without changing other lexer behavior.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.