Skip to content

Commit 889f913

Browse files
committed
test: cover malformed Content-Type last-resort branch
1 parent 81d9341 commit 889f913

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

spec/vulnerabilities.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,28 @@ describe('Vulnerabilities', () => {
18931893
const contentTypeArg = spy.calls.mostRecent().args[2];
18941894
expect(contentTypeArg).not.toMatch(/svg|html|xml|xhtml|xslt|mathml/i);
18951895
});
1896+
1897+
it('falls back to raw Content-Type when Content-Type is malformed (no slash)', async () => {
1898+
// Exercises the last-resort branch: when both the filename has no usable
1899+
// extension AND the Content-Type lacks a "/" subtype to parse, the raw
1900+
// Content-Type is used as the extension so a malformed header that
1901+
// matches a blocked pattern still trips the blocklist.
1902+
await expectAsync(
1903+
request({
1904+
method: 'POST',
1905+
headers: {
1906+
...headers,
1907+
'Content-Type': 'svg',
1908+
},
1909+
url: 'http://localhost:8378/1/files/poc',
1910+
body: '<svg/>',
1911+
}).catch(e => {
1912+
throw new Error(e.data.error);
1913+
})
1914+
).toBeRejectedWith(jasmine.objectContaining({
1915+
message: jasmine.stringMatching(/File upload of extension svg is disabled/),
1916+
}));
1917+
});
18961918
});
18971919

18981920
describe('(GHSA-q3vj-96h2-gwvg) SQL Injection via Increment amount on nested Object field', () => {

0 commit comments

Comments
 (0)