fix(isBase64): simplify padding RegExp to prevent stack overflow by KrayzeeKev · Pull Request #2574 · validatorjs/validator.js
Solves #2491 and #2573
Separate length check and then simplify regex to match any number of valid characters and 0 to 2 = on the end. Length check will ensure the {4} grouping is no longer necessary.
Checklist
- PR contains only changes related; no stray files, etc.
- README updated (where applicable)
- Tests written (where applicable)
- References provided in PR (where applicable)
Codecov Report
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (abcc8ec) to head (12211ff).
⚠️ Report is 1 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@ ## master #2574 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 114 114 Lines 2535 2536 +1 Branches 641 642 +1 ========================================= + Hits 2535 2536 +1
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Who is able to provide additional approvals and get this published? We've got production issues as a result of this. Need to decide whether we downgrade or hold out.
Also here with same issue on production. Currently using in nestjs class-validator library, which depends on this library. This a big problem for some partners, which send large documents. Here is an example:
example_fail.pdf
base64.txt
WikiRik
changed the title
feat(isBase64) #2491 #2573 Simplify isBase64 to prevent stack overflow
fix(isBase64): simplify padding RegExp to prevent stack overflow
@rubiin are you able to review this soon? After merging this I want to get another release out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters