]> git.immae.eu Git - github/shaarli/Shaarli.git/commit - index.php
Session ID: extend the regex to match possible hash representations 338/head
authorVirtualTam <virtualtam@flibidi.net>
Thu, 3 Sep 2015 21:12:58 +0000 (23:12 +0200)
committerVirtualTam <virtualtam@flibidi.net>
Sun, 6 Sep 2015 14:14:24 +0000 (16:14 +0200)
commit68bc21353a6138a898724c8bb87684bb2b6b2c1c
tree8c100e6ca4cba5870640cf3e0ec688b1f0fa7474
parenta02257b8aed58ef2f8536c877ce2fb222f84ac40
Session ID: extend the regex to match possible hash representations

Improves #306
Relates to #335 & #336
Duplicated by #339

Issues:
 - PHP regenerates the session ID if it is not compliant
 - the regex checking the session ID does not cover all cases
   - different algorithms: md5, sha1, sha256, etc.
   - bit representations: 4, 5, 6

Fix:
 - `index.php`:
   - remove `uniqid()` usage
   - call `session_regenerate_id()` if an invalid cookie is detected
 - regex: support all possible characters - '[a-zA-Z,-]{2,128}'
 - tests: add coverage for all algorithms & bit representations

See:
 - http://php.net/manual/en/session.configuration.php#ini.session.hash-function
 - https://secure.php.net/manual/en/session.configuration.php#ini.session.hash-bits-per-character
 - http://php.net/manual/en/function.session-id.php
 - http://php.net/manual/en/function.session-regenerate-id.php
 - http://php.net/manual/en/function.hash-algos.php

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
application/Utils.php
index.php
tests/UtilsTest.php
tests/utils/ReferenceSessionIdHashes.php [new file with mode: 0644]