Properly close snapshot if referer invalid

This commit is contained in:
Amos Ng 2020-06-29 06:42:44 +08:00
parent d24c061cc6
commit 620a859d5c
No known key found for this signature in database
GPG key ID: 89086414F634D123

View file

@ -105,6 +105,10 @@ class ImageServer(private val cache: DiskLruCache, private val statistics: Atomi
handled.set(true) handled.set(true)
if (referer != null && !referer.startsWith("https://mangadex.org")) { if (referer != null && !referer.startsWith("https://mangadex.org")) {
if (snapshot != null) {
snapshot.close()
}
Response(Status.FORBIDDEN) Response(Status.FORBIDDEN)
} else if (snapshot != null && imageDatum != null) { } else if (snapshot != null && imageDatum != null) {
request.handleCacheHit(sanitizedUri, getRc4(rc4Bytes), snapshot, imageDatum) request.handleCacheHit(sanitizedUri, getRc4(rc4Bytes), snapshot, imageDatum)