Skip to content

slugify: letters without decomposition removed by default, strip_tags() truncating at a '<', no multibyte lowercase, TypeError on non-string inputs #400

Closed

Description

@njoubert-cleverage

The slugify transformer loses or truncates text:

  • Letters without decomposition are removed: the default transliterator (NFD; [:Nonspacing Mark:] Remove; NFC) only removes the accents. The letters that are not decomposed are then removed by the default replace pattern: "Cœur" gives c_ur, "Straße" stra_e, "Łódź" odz, and a text without latin letters gives "". The documentation does not say so.
  • strip_tags() truncates any text containing a <: "Tom<Jerry" gives tom, "<3 love" gives "". It cannot be disabled.
  • Lowercasing is not multibyte: strtolower() leaves the non-ASCII uppercase letters kept by a custom transliterator / replace pattern.
  • Inputs other than a string: null, an int or a float throw a raw TypeError (Transliterator::transliterate() with strict types).

Fix: document the default transliterator and recommend Any-Latin; Latin-ASCII; new strip_tags option (true by default); mb_strtolower(); cast the scalars and \Stringable to string, explicit UnexpectedValueException for the other values. Changing the defaults (transliterator, strip_tags) is left to v6.0.

Found during the audit v3 (audit-v3-angles.md #193, #194, and #202 for slugify).

Activity

  1. added a commit that references this issue on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions