Fix JAGGRAB request parsing

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

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 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 @Singleton
public class FileProvider { public class FileProvider {
public fun get(uri: String): FileRegion? { public fun get(uri: String): FileRegion? {
if (!uri.startsWith("/")) { var path = ROOT.resolve(uri).toAbsolutePath().normalize()
return null
}
var path = ROOT.resolve(uri.substring(1)).toAbsolutePath().normalize()
if (!path.startsWith(ROOT)) { if (!path.startsWith(ROOT)) {
return null return null
} }

@ -25,7 +25,13 @@ public class HttpChannelHandler @Inject constructor(
} }
override fun channelRead0(ctx: ChannelHandlerContext, msg: HttpRequest) { 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) { if (file == null) {
ctx.write(createResponse(HttpResponseStatus.NOT_FOUND)).addListener(ChannelFutureListener.CLOSE) ctx.write(createResponse(HttpResponseStatus.NOT_FOUND)).addListener(ChannelFutureListener.CLOSE)
return return

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

Loading…
Cancel
Save