Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Update: XSS URL parameter sanitisation #91

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

### 1.7.8

* Updated: Requests containing URL parameters are now sanitised to prevent XSS attacks

### 1.7.7
* Fixed: More deprecated required parameter follows optional parameter warnings

Expand Down
9 changes: 9 additions & 0 deletions src/UrlHandlers/UrlHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ protected function getAbsoluteHandledUrl()
return $request->server("REQUEST_SCHEME") . "://" . $request->server("SERVER_NAME") . $this->handledUrl;
}

private function sanitizeRequest($request) {
$request->uri = htmlspecialchars($request->uri);
return $request;
}

/**
* Return the response when appropriate or false if no response could be generated.
*
Expand All @@ -277,6 +282,10 @@ protected function getAbsoluteHandledUrl()
*/
public function generateResponse($request = null, $currentUrlFragment = false)
{
if ($request !== null) {
$request = $this->sanitizeRequest($request);
}

if ($currentUrlFragment === false) {
$currentUrlFragment = $request->urlPath;
}
Expand Down