ezyang / ezyang/htmlpurifier

ValueError: Path cannot be empty in file_put_contents()

Open
#480 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

The problem occurs here:

https://github.com/ezyang/htmlpurifier/blob/b287d2a16aceffbf6e0295559b39662612b77fcf/library/HTMLPurifier/URIScheme/data.php#L89-L94

tempnam() can return false, which leads to file_put_contents() throwing ValueError: Path cannot be empty on PHP 8+.

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 at library/HTMLPurifier/URIScheme/data.php lines 89-94 and inspect how tempnam() is used before file_put_contents(). Reproduce the failure on PHP 8+ and check the surrounding URI data handling. Done means tempnam() failure no longer reaches file_put_contents() with an invalid path, with the existing behavior preserved for successful temporary-file creation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.