Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@ All notable changes to **initphp/translator** will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [2.0.1] - 2026-11-25

### Security

- **Affected versions: every release up to and including 2.0.0** (0.1, 0.2, 1.0.0
and 2.0.0 were checked: none of them validates the language identifier before it
is joined into a path that is `require`d or passed to `glob()`).
- `setDefault()` and `change()` now reject a language identifier that is empty,
contains `/`, `\` or a NUL byte, or consists only of dots and spaces (`.`, `..`,
and the forms Windows normalises to them) by throwing `TranslatorException`
before any file is read. Previously the identifier was joined into the path of a
file that was `require`d, so a request-supplied value such as `../config/install`
could run PHP files outside the language directory. Codes that pointed into a
sub-directory of the language directory (`sub/en`, and `sub\en` on POSIX) worked
in 2.0.0 in both modes and are now rejected; a language pack must sit directly
in the language directory (or be a directory of its own in directory mode).
sub-directory of the language directory worked in 2.0.0 (`sub/en`, and `sub\en`
on Windows) and are now rejected, and so is a file name containing `\` on POSIX;
a language pack must sit directly in the language directory (or be a directory of
its own in directory mode).
Every other name keeps working exactly as in 2.0.0 (`en_US`, `pt-BR`,
`sr@latin`, `zh.Hant`, `türkçe`, names with a space). On Windows a `:` is also
rejected, as it is not valid in a file name there. The translator's state is unchanged when a code is rejected.
Rejecting these codes (a sub-directory path, an empty code, or one made only of
dots and spaces such as `.`) is the incompatible change of this release: for
example `useDirectory()->setDefault('.')` loaded the files of the language
directory itself in 2.0.0 and now throws. It ships as a patch release so that
installations on `^2.0` get the fix.
- In directory mode the language path is matched literally by `glob()`: `*`, `?`
and `[` in a language code or in the base directory are no longer wildcards, so
a directory named like `.*` cannot also pull in the files of its parent.
Expand All @@ -35,6 +44,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
loaded. Before, a broken file left a half-loaded language in the cache, and
the next `change()` to it succeeded silently with the missing namespaces.

### Documentation

- The README, API reference, Exceptions, Quick Start and Recipes describe which
language codes are rejected (empty, `/`, `\`, NUL, only dots and spaces, and `:`
on Windows), that a rejected or unloadable code leaves the translator as it was,
that `*`, `?` and `[` are matched literally in directory mode, and that a
well-formed but unsupported code still throws, so a language taken from a request
must be checked against an allow-list first.

## [2.0.0] - 2026-11-22

### Changed (breaking)
Expand Down
Loading