NEWPractise supported commands in browser simulations, alongside the lesson.Try a browser practice exercise.Try a lab♥ Codelivly is 100% free, no paywall. If it helped you, chip in to keep it running.100% free. Help keep it so.Support us
Preview · 35 min
How to check which claim about an uploaded file the server believes, test a receipt upload with three inert samples, and recommend an allow list based on content.
At 13:33 on Thursday 2027-07-01 Ben tried to attach mf014-notes.png to the test expense exp_7303. The name ended in .png and the request said image/png, but the file held one line of plain text. Ledgerline answered 422 and kept nothing. Five minutes later he sent a small drawing to exp_7301, again declared as image/png. The drawing was an SVG file. This time the answer was 201 and a new receipt id, rcp_8951.
Both requests went from the same account with the same declared type. The refused file carried the .png name and the accepted one a .svg name, so neither the declared type nor a trusted .png name explains the two answers. The server read the content, and then accepted something the receipt rule does not allow. An upload check has two parts, finding out what a file is and deciding whether that kind is permitted, and a mistake in either one produces an accepted file that should have been refused.
Create a free account to unlock the rest of this task, complete tasks, and earn Rep.
Sign in