Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelogs/v4.7.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Release Date: Unreleased
- **Debug Toolbar:** Fixed a bug where `History::setFiles()` emitted a PHP warning when attempting to delete a debugbar history file that had already been removed.
- **Helpers:** Fixed a bug in `ellipsize()` where `$position` was clamped after slicing the beginning of the string and where float `1.0` was not treated identically to integer `1`.
- **Helpers:** Fixed a bug where `excerpt()` threw a `TypeError` when `$phrase` was not found in `$text` or when `$phrase` was `null` and `$radius` was an odd integer. When `$phrase` is not found, `excerpt()` now falls back to extracting an excerpt from the beginning of `$text`.
- **Helpers:** Fixed a bug where `form_open()` did not escape the `$action` attribute value, allowing quotes or HTML characters in absolute URLs to break out of the `action` attribute.
- **Helpers:** Fixed a bug where `format_number()` with `$precision = 0` appended a trailing comma in locales using a comma as the decimal separator.
- **Helpers:** Fixed a bug where `parse_subdomain()` incorrectly treated hostnames with ports (such as IP addresses and two-part TLD domains) as having unexpected subdomains.
- **Helpers:** Fixed a bug in `plural()` where the regex for `matrix`, `vertex`, and `index` lacked non-capturing grouping and an end-of-string anchor for the `ix` alternative, causing incorrect pluralization of words like `complex`, `sex`, and strings containing `matrix` before the end. Expanded `plural()` and `singular()` to support additional words ending in `ix` or `ex` (`apex`, `appendix`, `codex`, `cortex`, `latex`, `murex`, `vortex`).
Expand Down
2 changes: 1 addition & 1 deletion system/Helpers/form_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s
$attributes .= ' accept-charset="' . strtolower($config->charset) . '"';
}

$form = '<form action="' . $action . '"' . $attributes . ">\n";
$form = '<form action="' . esc($action) . '"' . $attributes . ">\n";

// Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
$before = service('filters')->getFilters()['before'];
Expand Down
18 changes: 18 additions & 0 deletions tests/system/Helpers/FormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ public function testFormOpenWithoutMethod(): void
$this->assertSame($expected, form_open('foo/bar', $attributes));
}

public function testFormOpenEscapesAction(): void
{
$this->setRequest();

$payload = 'https://example.com/" onclick="alert(1)" data-x="';
$expected = <<<'EOH'
<form action="https://example.com/&quot; onclick=&quot;alert(1)&quot; data-x=&quot;" method="post" accept-charset="utf-8">

EOH;
$this->assertSame($expected, form_open($payload));

$expectedQuery = <<<'EOH'
<form action="https://example.com/search?a=1&amp;b=2" method="post" accept-charset="utf-8">

EOH;
$this->assertSame($expectedQuery, form_open('https://example.com/search?a=1&b=2'));
}

public function testFormOpenWithoutMethodWithCsrf(): void
{
$this->setRequest();
Expand Down
Loading