Skip to content

Commit

Permalink
Merge pull request #66 from fritzmg/remove-trailing-semicolon
Browse files Browse the repository at this point in the history
Remove trailing semicolon
  • Loading branch information
paragonie-security authored Mar 26, 2023
2 parents acdda0e + 0f1a7f7 commit 172dc0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CSPBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function compile(): string
$compiled []= 'upgrade-insecure-requests';
}

$this->compiled = implode('', $compiled);
$this->compiled = rtrim(implode('', $compiled), '; ');
$this->needsCompile = false;
return $this->compiled;
}
Expand Down
17 changes: 17 additions & 0 deletions test/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ public function testBasicFromData()
);
}

/**
* @throws \Exception
*/
public function testNoTrailingSemicolon()
{
$csp = (new CSPBuilder())
->setSelfAllowed('default-src', true)
->addSource('img-src', 'ytimg.com')
->disableOldBrowserSupport()
;

$this->assertEquals(
"default-src 'self'; img-src ytimg.com",
$csp->getCompiledHeader()
);
}

/**
* @throws \Exception
*/
Expand Down

0 comments on commit 172dc0a

Please sign in to comment.