Skip to content

Commit e636912

Browse files
authored
Merge pull request #64 from namecheap/fix/redirect-vulnerability-yet-another-case
fix: yet another case when redirect passes through due to url malformation
2 parents 50d5290 + 8a7a6e6 commit e636912

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ilc-sdk",
3-
"version": "5.2.1",
3+
"version": "5.2.4",
44
"description": "SDK for app development with Isomorphic Layout Composer",
55
"main": "dist/server/index.js",
66
"types": "dist/server/index.d.ts",

src/app/utils/parseAsFullyQualifiedURI.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
export default function parseAsFullyQualifiedURI(uri: string) {
22
let origin = '';
33
try {
4+
// Normalize multiple slashes to a single slash, but don't affect the initial "http://" or "https://"
5+
uri = uri.replace(/([^:])\/{2,}/g, '$1/');
6+
47
const urlObj = new URL(uri);
58
origin = urlObj.origin;
69

7-
// Apply replacement only to the pathname, leaving the rest (search, hash) intact
8-
urlObj.pathname = urlObj.pathname.replace(/\/{2,}/g, '/');
9-
1010
uri = urlObj.pathname + urlObj.search + urlObj.hash;
1111
} catch {}
1212

test/app/IlcIntl.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ describe('IlcIntl', () => {
199199
});
200200
});
201201

202+
it('returns locale with normalized route when multiple slashes are present', () => {
203+
expect(IlcIntl.parseUrl(baseConfig, '/es///tst.com')).to.eql({
204+
cleanUrl: '/tst.com',
205+
locale: 'es-ES',
206+
});
207+
});
208+
202209
it('returns locale with default culture when no culture present in the route', () => {
203210
expect(IlcIntl.parseUrl(baseConfig, '/es-MX/tst')).to.eql({
204211
cleanUrl: '/tst',

0 commit comments

Comments
 (0)