mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
(security) improve pronunciation endpoint length check
eg.: <speak><phoneme ph="sʌm ɪnˈtaɪər ˈʃeɪkspɪər tɛkst ɪn ˈaɪpiːˈeɪ"/></speak>
This commit is contained in:
parent
bd2ac79c49
commit
5a6315ad47
@ -31,7 +31,8 @@ router.get('/pronounce/:voice/:pronoun*', handleErrorAsync(async (req, res) => {
|
||||
|
||||
const text = example.pronounce(pronoun);
|
||||
|
||||
if (!text || text.replace(/<[^>]+>/g, '').length > 256) {
|
||||
// quick length check to avoid abuse. remove SSML tags but keep both tag value and attributes
|
||||
if (!text || text.replace(/<[^ ]+/g, '').replace('>', '').length > 256) {
|
||||
return res.status(404).json({error: 'Not found'});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user