quoted_printable_encode() produces lines longer than 76 characters for bytes 0xF5 to 0xFF
維護者通常 1 天內回覆
評估
研究方向
從 ext/standard/quot_print.c 中的 php_quot_print_encode() 開始,比較位元組 0xF5 到 0xFF 的軟換行處理與現有分支。檢查相關的 quoted-printable 測試,並為這些位元組連續出現的情況新增測試涵蓋。編碼後的行不超過 RFC 2045 規定的 76 個字元即表示完成;issue 指出串流篩選器不受影響。
由索引模型根據 Issue 內容生成。
描述
Description
quoted_printable_encode() is documented to follow RFC 2045 section 6.7, which limits encoded lines to 76 characters. Input bytes in the range 0xF5 to 0xFF are encoded as =XX but never trigger a soft line break, so a run of them ends up on a single line of any length.
The following code:
<?php
$encoded = quoted_printable_encode(str_repeat("\xFF", 30));
var_dump(array_map('strlen', explode("\r\n", $encoded)));
Resulted in this output:
array(1) {
[0]=>
int(90)
}
But I expected this output instead:
array(2) {
[0]=>
int(76)
[1]=>
int(15)
}
The same happens with any binary data that contains such bytes, for example a random string of a few hundred bytes regularly produces 78 or 79 character lines. The convert.quoted-printable-encode stream filter is not affected.
Root cause: in php_quot_print_encode() (ext/standard/quot_print.c) the soft break condition has one branch for bytes up to 0x7F and three branches for UTF-8 lead and continuation bytes (0x80 to 0xDF, 0xE0 to 0xEF, 0xF0 to 0xF4). Bytes 0xF5 to 0xFF match none of them, so the line position keeps growing without a break being inserted.
PHP Version
PHP 8.7.0-dev (master at b7256eee), also present in all supported branches
Operating System
Any
- 主要語言
- C
- 星號
- 40.4k
- 分支
- 8.2k
- 平均合併
- 3 天 3 小時
- 30 天內合併 PR
- 173
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
php/php-src 的其他 Issue
-
Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 64/100
維護者通常 1 天內回覆
-
standard/syslog: the request shutdown hook calls closelog() even when the request never opened syslog可能已有人在做 @lazerg 於 7 天前認領。 未關閉Bug Extension: standard Status: Verified
難度 2/5 半天 新手友好度 62/100
維護者通常 1 天內回覆
-
Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
Feature Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 73/100
維護者通常 1 天內回覆
-
Sockets from synchronous stream_socket_client() are left in non-blocking mode on Windows可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 1 天內回覆
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
bug Component component: net
難度 2/5 1-3 小時 新手友好度 78/100
RT-Thread/rt-thread#11913 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
contiki-ng/contiki-ng#3289 ·
維護者通常 3 天內回覆
-
area:docs help wanted type:enhancement
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 83/100
semantic-reasoning/wirelog#2229 ·
維護者通常 1 天內回覆