Fix JAGGRAB request parsing

The paths aren't prefixed with a slash, unlike HTTP.

Signed-off-by: Graham <gpe@openrs2.org>
pull/132/head
Graham 3 years ago
parent 7eae597892
commit 440711def0
  1. 6
      game/src/main/kotlin/org/openrs2/game/net/FileProvider.kt
  2. 8
      game/src/main/kotlin/org/openrs2/game/net/http/HttpChannelHandler.kt
  3. 2
      share/doc/protocol/jaggrab.md

@ -10,11 +10,7 @@ import javax.inject.Singleton
@Singleton
public class FileProvider {
public fun get(uri: String): FileRegion? {
if (!uri.startsWith("/")) {
return null
}
var path = ROOT.resolve(uri.substring(1)).toAbsolutePath().normalize()
var path = ROOT.resolve(uri).toAbsolutePath().normalize()
if (!path.startsWith(ROOT)) {
return null
}

@ -25,7 +25,13 @@ public class HttpChannelHandler @Inject constructor(
}
override fun channelRead0(ctx: ChannelHandlerContext, msg: HttpRequest) {
val file = fileProvider.get(msg.uri())
val uri = msg.uri()
if (!uri.startsWith("/")) {
ctx.write(createResponse(HttpResponseStatus.BAD_REQUEST)).addListener(ChannelFutureListener.CLOSE)
return
}
val file = fileProvider.get(uri.substring(1))
if (file == null) {
ctx.write(createResponse(HttpResponseStatus.NOT_FOUND)).addListener(ChannelFutureListener.CLOSE)
return

@ -10,7 +10,7 @@ contains a single opcode byte: `17`.
The loader then writes the following string:
JAGGRAB /<file name>
JAGGRAB <file name>
where `<file name>` is replaced with the name of the file to fetch. The string
is followed by two line feed characters.

Loading…
Cancel
Save