Api: Fix favorites with non-ascii names could overlap

This commit is contained in:
nathan
2024-03-04 15:12:54 -07:00
parent 98cf3415ca
commit b1f20ddbb8
3 changed files with 38 additions and 5 deletions

View File

@ -338,6 +338,20 @@ egw.extend('utils', egw.MODULE_GLOBAL, function()
return _comp.replace(/%/g,'%25').replace(/#/g,'%23').replace(/\?/g,'%3F').replace(/\//g,'');
},
/**
* Hash a string
*
* @param string
*/
async hashString(string)
{
const data = (new TextEncoder()).encode(string);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(byte => byte.toString(16).padStart(2, '0')).join('');
return hashHex;
},
/**
* Escape HTML special chars, just like PHP
*