Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

WordPress plugin 1.0.0: proxy drops Content-Type (all events rejected) and inline SDK is always rejected

オープン 初心者向け
#610 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
73/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, wordpress
領域
api, backend

調査の方向性

openpanel.phpから始め、collect_request_headers()、proxy_request()、is_valid_javascript_content()に注目してください。リクエストヘッダーとインラインSDKの検証がイベント転送にどう影響するかを追い、その後、プロキシのレスポンス処理を確認してください。完了条件は、プロキシがContent-Typeを転送し、説明されているSDKスクリプトを受け入れ、upstreamのレスポンスをJSONオブジェクトとして返すことです。issueには実行すべきテストは記載されていません。

索引モデルが issue の本文から書いたものです。

説明

The WordPress plugin (v1.0.0) doesn't track anything on our site, because of two bugs in openpanel.php.

1. Proxy drops the Content-Type header, so every event is rejected

collect_request_headers() only forwards $_SERVER keys starting with HTTP_. PHP stores the Content-Type under CONTENT_TYPE, without that prefix, so the proxy never forwards it. The API then rejects every event:

POST /wp-json/openpanel/track → 400 {"status":400,"error":"Error","message":"body/type Invalid input"}

The same request sent directly to api.openpanel.dev/track returns 200.

Fix in proxy_request():

$content_type = $request->get_header('content_type');
if ($content_type) {
    $incoming['Content-Type'] = $content_type;
}

2. The inline op1.js always fails validation, so the plugin falls back to the CDN script, which ad blockers block

is_valid_javascript_content() rejects any script that matches /on\w+\s*=/i. op1.js contains r.onload=, r.onerror= and this.options=, so the inlined SDK is rejected on every page load. The plugin then loads https://openpanel.dev/op1.js, which Safari and ad blockers block, which defeats the purpose of the proxy.

Fix: remove on\w+\s*= from the pattern. op1.js comes from your own HTTPS endpoint, so the check doesn't protect against anything.

if (preg_match('/(?:javascript:|data:|vbscript:)/i', $js_content)) {

With both changes, events arrive correctly, including from browsers with tracker blocking.

Smaller issue: proxy_request() passes the raw upstream body string to WP_REST_Response, which JSON-encodes it again. The browser therefore receives "{\"deviceId\":...}", a JSON string rather than an object. Decoding it first (json_decode($bodyOut)) would fix that.

Disclaimer: I wrote this Issue Description with the help of AI

主要言語
TypeScript
スター
7.2k
フォーク
523
平均マージ
15時間 24分
マージ済み PR(30日)
41

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Openpanel-dev/openpanel のほかの issue

Openpanel-dev/openpanel の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。