mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-22 15:25:20 +00:00
fix: replaced redundant writeHtmlEscaped method with writeCodepoint
This commit is contained in:
committed by
Mitchell Hashimoto
parent
5e265c9c0d
commit
9868bf3789
@@ -1283,13 +1283,13 @@ pub const PageFormatter = struct {
|
||||
const uri = link.uri.offset.ptr(self.page.memory)[0..link.uri.len];
|
||||
|
||||
try writer.writeAll("<a href=\"");
|
||||
try self.writeHtmlEscaped(writer, uri);
|
||||
for (uri) |byte| try self.writeCodepoint(writer, byte);
|
||||
try writer.writeAll("\">");
|
||||
|
||||
if (self.point_map) |*map| {
|
||||
var discarding: std.Io.Writer.Discarding = .init(&.{});
|
||||
try discarding.writer.writeAll("<a href=\"");
|
||||
try self.writeHtmlEscaped(&discarding.writer, uri);
|
||||
for (uri) |byte| try self.writeCodepoint(&discarding.writer, byte);
|
||||
try discarding.writer.writeAll("\">");
|
||||
|
||||
for (0..discarding.count) |_| map.map.append(map.alloc, .{
|
||||
@@ -1502,24 +1502,6 @@ pub const PageFormatter = struct {
|
||||
|
||||
/// Write a string with HTML escaping. Used for escaping href attributes
|
||||
/// and other HTML attribute values.
|
||||
fn writeHtmlEscaped(
|
||||
self: PageFormatter,
|
||||
writer: *std.Io.Writer,
|
||||
str: []const u8,
|
||||
) !void {
|
||||
_ = self;
|
||||
for (str) |byte| {
|
||||
switch (byte) {
|
||||
'<' => try writer.writeAll("<"),
|
||||
'>' => try writer.writeAll(">"),
|
||||
'&' => try writer.writeAll("&"),
|
||||
'"' => try writer.writeAll("""),
|
||||
'\'' => try writer.writeAll("'"),
|
||||
else => try writer.writeByte(byte),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn formatStyleOpen(
|
||||
self: PageFormatter,
|
||||
writer: *std.Io.Writer,
|
||||
|
||||
Reference in New Issue
Block a user