From 1d61c7250ee5bb4038a4e67144f88a78a5f8a4f9 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Tue, 11 Feb 2025 07:57:46 -0500 Subject: [PATCH] Update Readme.md --- Readme.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Readme.md b/Readme.md index d73ad1f..5a4bd1e 100644 --- a/Readme.md +++ b/Readme.md @@ -62,4 +62,24 @@ parse.unit = es parse('1 hora 20 minutos', 'm') // 80 ``` + +## Security Note + +To avoid issues with long strings in sensitive APIs, limit input length: + +```js +const MAX_INPUT_LENGTH = 100; + +function safeParse(input) { + if (input.length > MAX_INPUT_LENGTH) { + throw new Error('Input string is too long'); + } + return parseDuration(input); +} + +safeParse('1hr 20mins'); // => 1 * h + 20 * m +``` + + +