Skip to content

1.1.1#696

Merged
rubenarslan merged 3 commits into
masterfrom
hotfix/1.1.1
Jun 11, 2026
Merged

1.1.1#696
rubenarslan merged 3 commits into
masterfrom
hotfix/1.1.1

Conversation

@rubenarslan

@rubenarslan rubenarslan commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Fixes

  • ParsedownExtra fatal error (Call to a member function getAttribute() on null / TypeError: DOMNode::replaceChild(): Argument #1 ($node) must be of type DOMNode, null given) when a survey item label or run text field contains malformed HTML (e.g. a bare <head> tag). ParsedownExtra's DOMDocument block processor (processTagRoutine) dereferences DOM nodes without null checks and crashes with a PHP Error — not an Exception — so the existing catch (Exception) guard in SurveyStudy::addItems did not intercept it.
  • All Parsedown text() call sites now go through a new parsedown_text_safe() helper (Functions.php): catches \Throwable, stores the raw (unparsed) text, logs via formr_log_exception, and shows the study author a warning naming the affected field. Covered sites: survey item labels, choice labels, run description/public_blurb/footer_text/privacy/tos, email body, pause text, and page body (the chained call in Page::create() was unguarded in the first iteration of this PR).

Changes

  • Updated erusev/parsedown 1.7.4 → 1.8.0 and erusev/parsedown-extra 0.8.1 → 0.9.0 (February 2026 maintenance releases). Verified the upgrade alone does not fix the crash — 0.9.0 ships the same unguarded processTagRoutine — hence the call-site guard.

Tests

  • tests/ParsedownTextSafeTest.php: fallback to raw text on parser Error, author alert naming the source field, HTML-escaping of the source label, and the real-world <head> crash input against the live vendor lib. Full unit lane green (162 tests).

ParsedownExtra can throw PHP Error (not Exception) when DOMDocument
returns unexpected structure on malformed HTML input (e.g. a label
containing a bare <head> tag). The existing catch block in
SurveyStudy::addItems used `Exception`, which silently re-threw any
`Error`, crashing the survey import with a fatal.

Widen all seven call sites to `catch (\Throwable $e)` and fall back
to the raw text on failure, logging via formr_log_exception.

Sites fixed:
- SurveyStudy::addItems – item label + choice label
- Run::saveSettings – description, public_blurb, footer_text, privacy, tos
- Email::save – email body
- Pause::save – pause body
…cover Page.php, alert authors

- Replace the seven copy-pasted try/catch guards with a single
  parsedown_text_safe() helper in Functions.php
- Guard the previously missed chained ->text() call in Page::create()
- On parse failure, alert the study author naming the affected field
  instead of silently storing unparsed text
- Upgrade erusev/parsedown 1.7.4 -> 1.8.0 and erusev/parsedown-extra
  0.8.1 -> 0.9.0 (verified the upgrade alone does not fix the
  DOMDocument crash: 0.9.0 ships the same unguarded processTagRoutine)
- Add tests/ParsedownTextSafeTest.php covering fallback, author alert,
  HTML-escaping of the source label, and the real <head> crash input
@rubenarslan rubenarslan merged commit e9fdb41 into master Jun 11, 2026
4 checks passed
@rubenarslan rubenarslan deleted the hotfix/1.1.1 branch June 11, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant