Skip to content

Commit 8e1d6f7

Browse files
committed
Pull request review comment fixes
1 parent 37a83ff commit 8e1d6f7

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

libs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ CSRFProtector configuration
1515
- `customErrorMessage`: **Error Message** to be shown to user. Only this text will be shown!<br>**Default: null**
1616
- `jsUrl`: **Absolute url** of the js file. (See [Setting up](https://github.com/mebjas/CSRF-Protector-PHP/wiki/Setting-up-CSRF-Protector-PHP-in-your-web-application) for more information)
1717
- `tokenLength`: length of csrfp token, Default `10`
18-
- `cookieConfig`: Array of parameter values for set cookie method. supports three properties: `path`, `domain`, `secure`. They have same meaning as respective parameters of `setcookie` method in php have: [learn more - php.net]
18+
- `cookieConfig`: Array of parameter values for set cookie method. supports three properties: `path`, `domain`, `secure`. They have same meaning as respective parameters of `setcookie` method: [learn more - php.net]
1919
- `disabledJavascriptMessage`: messaged to be shown if js is disabled (string)
2020
- `verifyGetFor`: regex rules for those urls for which csrfp validation should be enabled for `GET` requests also. (View [verifyGetFor rules](https://github.com/mebjas/CSRF-Protector-PHP/wiki/verifyGetFor-rules) for more information)

test/csrfprotector_test.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,19 @@ public function testSecureCookie()
179179
$_SERVER['REQUEST_METHOD'] = 'POST';
180180
$_SESSION[csrfprotector::$config['CSRFP_TOKEN']] = array('123abcd');
181181

182-
csrfprotector::$config['cookieConfig'] = array('secure' => false);
183-
csrfprotector::refreshToken();
184-
$this->assertNotRegExp('/; secure/', csrfp_wrapper::getHeaderValue('Set-Cookie'));
185-
186182
// this one would generally fails, as init was already called and now private static
187183
// property is set with secure as false;
188184
$csrfp = new csrfProtector;
189185
$reflection = new \ReflectionClass(get_class($csrfp));
190186
$property = $reflection->getProperty('cookieConfig');
191187
$property->setAccessible(true);
188+
189+
// change value to false
190+
$property->setValue($csrfp, new cookieConfig(array('secure' => false)));
191+
csrfprotector::refreshToken();
192+
$this->assertNotRegExp('/; secure/', csrfp_wrapper::getHeaderValue('Set-Cookie'));
193+
194+
// change value to true
192195
$property->setValue($csrfp, new cookieConfig(array('secure' => true)));
193196
csrfprotector::refreshToken();
194197
$this->assertRegExp('/; secure/', csrfp_wrapper::getHeaderValue('Set-Cookie'));

0 commit comments

Comments
 (0)