add preg_quote_replacement() function
オープン
まだ誰も着手していません。
Extension: pcre
Feature
Status: Needs Triage
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
$pattern = '/[[name]]/';
$template = 'My name is [[name]]';
preg_replace($pattern, $_POST['name'], $template);
This is prone to injection of any match from the pattern if user supplies for example Tomas$1Fejfar. There is a preg_quote function that can be used to escape special chars in template. There should be same function that would escape the replacement.
preg_quote_replacement($_POST['name']); // Tomas\$1Fejfar
IMHO it is enough to escape backslash and dollars with backslash, but I am not sure.
Currently the replacement must be escaped using userland function that makes it prone to mistakes.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue では preg_quote() と preg_replace() が挙げられていますが、ファイルもテストも提供されていません。まずそれらの実装と置換の解析を追跡し、次に、示されている injection ケースに対して、バックスラッシュとドル記号の提案された扱いを検証してください。完了の条件は、エスケープの契約を定義し、新しい関数を実装し、Tomas$1Fejfar のような置換文字列のカバレッジを追加することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100