From f659fcf58634a813fa4895895bf56d1e05dd0a51 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 16 Jan 2025 23:40:10 +0100 Subject: [PATCH] feat(lsp): rename_symbol: add checks to file uri decoding --- src/Project.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Project.zig b/src/Project.zig index 910bb7b..3750025 100644 --- a/src/Project.zig +++ b/src/Project.zig @@ -815,8 +815,15 @@ pub fn rename_symbol(self: *Self, from: tp.pid_ref, file_path: []const u8, row: try cbor.writeValue(w, "rename_symbol_item"); try cbor.writeArrayHeader(w, renames.items.len); for (renames.items) |rename| { + if (!std.mem.eql(u8, rename.uri[0..7], "file://")) return error.InvalidTargetURI; var file_path_buf: [std.fs.max_path_bytes]u8 = undefined; const file_path_ = std.Uri.percentDecodeBackwards(&file_path_buf, rename.uri[7..]); + if (builtin.os.tag == .windows) { + if (file_path[0] == '/') file_path = file_path[1..]; + for (file_path, 0..) |c, i| if (c == '/') { + file_path[i] = '\\'; + }; + } const line = try self.get_line_of_file(self.allocator, file_path, rename.range.start.line); try cbor.writeValue(w, .{ file_path_,