Forms get a second csrfToken field: two XPath expressions in document.php miss the @

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

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

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

評価

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

調査の方向性

system/core/document.phpで、issue は363行目と510行目の2つのXPath式を特定しています。それらの行の付近でfindOneXPathがどのように使われているかを読み、属性テストを修正した後、フォームの出力にCSRFトークンが1つ、エラーリストが1つ含まれていることを確認してください。issueにはnl/Start/editでの再現手順があります。重複したフィールドとリストがなくなったことを確認してください。

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

説明

Impact: Low Level: Easy Type: Bug Value: Coders

Problem. Every HTMLForm gets a second csrfToken input, and a form may get a second error list, because two XPath expressions in system/core/document.php test a child element instead of an attribute (the @ is missing):

  • line 363: $this->form_element->findOneXPath('input[name=csrfToken]') compares a child element name with a child element csrfToken, so it never finds the existing token and always adds one more;
  • line 510: findOneXPath(".//ul[class='form-errors']") compares a child element class, so it never finds the existing list and adds another one.

Steps to reproduce (fictional test site, main d97ab7b, PHP 8.2). Log in as an administrator and open nl/Start/edit: the page holds name="csrfToken" twice. Both carry the same value, so nothing breaks today, but the form markup is wrong and the second error list can show errors twice.

Proposed fix. input[@name='csrfToken'] and .//ul[@class='form-errors'].

Found while writing known-bug tests for #520.

🤖 Generated with Claude Code

主要言語
JavaScript
スター
5
フォーク
9
平均マージ
18時間 49分
マージ済み PR(30日)
13

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

PlanBCode/hypha のほかの issue

PlanBCode/hypha の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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