mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 20:18:52 +02:00
🎨 Block ID generation : less risk of id collision
Reported by NonSecureUniqidUsageInspection : when calling \uniqid we should provide true as second parameter.
But was causing issues as the generated string could contain a dot, and this is used in CSS and JQuery selectors (for example a "my.id" cannot be used in #my.id selector)
So we're just replacing dots with hyphens !
Was discussed with @Molkobain in 0119f6c395
This commit is contained in:
@@ -184,14 +184,16 @@ abstract class UIBlock implements iUIBlock
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a unique ID for the block
|
||||
* **Warning**, this shouldn't generate any dot as this will be used in CSS and JQuery selectors !
|
||||
*
|
||||
* @return string
|
||||
* @return string a unique ID for the block
|
||||
*/
|
||||
protected function GenerateId()
|
||||
{
|
||||
/** @noinspection NonSecureUniqidUsageInspection see https://github.com/Combodo/iTop/commit/0119f6c395f314452b74c79182f4426ecff1c36d#r43596531 */
|
||||
return uniqid(static::BLOCK_CODE.'-');
|
||||
$sUniqId = uniqid(static::BLOCK_CODE.'-', true);
|
||||
$sUniqId = str_replace('.', '-', $sUniqId);
|
||||
|
||||
return $sUniqId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user