If you were locked in a room with a gorilla for ten minutes with only a kitchen knife and pepper spray, would you survive?
Sure you can, but not if you’re stupid enough to attack the gorilla with a knife and pepper spray.
Gorillas don’t attack for no reason, but like anything they will attack a threat. Assuming it’s a silverback, then you have the added problem that it’s extremely dominant and any perceived challenge will get you seriously hurt.
So don’t look like a threat, and don’t look like you’re challenging him. Some zoological knowledge may help here, but we’re quite closely related and we actually have a pretty similar idea of what constitutes a threat or a challenge- you can figure this out.
You avoid eye contact, sit as far away from him as possible curled up as small as you can go, and you don’t make sudden movements or loud noises. Look submissive, look non-threatening.
There is one rather daft answer that claims the gorilla is as scared as you are and you can take him in a fight with your superior brain power. That person would not be coming out of this situation alive.
A fully-grown silverback is around 20x stronger than the average human male. They have been recorded lifting and throwing weights up to 815kg (almost 1,800lbs).
They’re also about twice as heavy as the average American male, with an arm-span about a third again as long.
You think pepper spray and a paring knife are going to stop a gorilla?
The second you look like you’re challenging him you’re toast. Sit down, be quiet, be small, move slowly, and you’ll probably make it out just fine.