[PR #683] [MERGED] Attempt to recover from json encoding errors #1296

Closed
opened 2026-03-04 03:08:59 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Seldaek/monolog/pull/683
Author: @bd808
Created: 11/12/2015
Status: Merged
Merged: 11/18/2015
Merged by: @Seldaek

Base: masterHead: feature/clean-json


📝 Commits (1)

  • 6f9e221 Attempt to recover from json encoding errors

📊 Changes

3 files changed (+225 additions, -10 deletions)

View changed files

📝 src/Monolog/Formatter/NormalizerFormatter.php (+90 -7)
📝 tests/Monolog/Formatter/LogstashFormatterTest.php (+43 -0)
📝 tests/Monolog/Formatter/NormalizerFormatterTest.php (+92 -3)

📄 Description

Detect and attempt to recover from json_encode errors triggered by
strings containing invalid UTF-8 sequences. Recovery will only be
attempted when encoding strings or arrays. If recovery fails then
a RuntimeException will be thrown.

The recovery process will convert invalid UTF-8 codepoints as though the
input string was encoded using the ISO-8859-15 character encoding. This
conversion may result in incorrect string output if the original
encoding was not ISO-8859-15, but it will be a valid UTF-8 string.

Closes #545 and possibly #616


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Seldaek/monolog/pull/683 **Author:** [@bd808](https://github.com/bd808) **Created:** 11/12/2015 **Status:** ✅ Merged **Merged:** 11/18/2015 **Merged by:** [@Seldaek](https://github.com/Seldaek) **Base:** `master` ← **Head:** `feature/clean-json` --- ### 📝 Commits (1) - [`6f9e221`](https://github.com/Seldaek/monolog/commit/6f9e221bd62d2d95170e13aad6ad2a45044c5e2c) Attempt to recover from json encoding errors ### 📊 Changes **3 files changed** (+225 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/Monolog/Formatter/NormalizerFormatter.php` (+90 -7) 📝 `tests/Monolog/Formatter/LogstashFormatterTest.php` (+43 -0) 📝 `tests/Monolog/Formatter/NormalizerFormatterTest.php` (+92 -3) </details> ### 📄 Description Detect and attempt to recover from json_encode errors triggered by strings containing invalid UTF-8 sequences. Recovery will only be attempted when encoding strings or arrays. If recovery fails then a RuntimeException will be thrown. The recovery process will convert invalid UTF-8 codepoints as though the input string was encoded using the ISO-8859-15 character encoding. This conversion may result in incorrect string output if the original encoding was not ISO-8859-15, but it will be a valid UTF-8 string. Closes #545 and possibly #616 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 03:08:59 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#1296
No description provided.