mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
fix: log SJIS decoding errors instead of silently discarding them
Add SJISToUTF8Lossy() that wraps SJISToUTF8() and logs decode errors at slog.Debug level. Replace all 31 call sites across 17 files that previously discarded the error with `_, _ =`. This makes garbled text from malformed SJIS client data debuggable without adding noise at default log levels.
This commit is contained in:
@@ -30,9 +30,9 @@ func (m *MsgMhfApplyBbsArticle) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cl
|
||||
m.AckHandle = bf.ReadUint32()
|
||||
m.Unk0 = bf.ReadUint32()
|
||||
m.Unk1 = bf.ReadBytes(16)
|
||||
m.Name, _ = stringsupport.SJISToUTF8(bfutil.UpToNull(bf.ReadBytes(32)))
|
||||
m.Title, _ = stringsupport.SJISToUTF8(bfutil.UpToNull(bf.ReadBytes(128)))
|
||||
m.Description, _ = stringsupport.SJISToUTF8(bfutil.UpToNull(bf.ReadBytes(256)))
|
||||
m.Name = stringsupport.SJISToUTF8Lossy(bfutil.UpToNull(bf.ReadBytes(32)))
|
||||
m.Title = stringsupport.SJISToUTF8Lossy(bfutil.UpToNull(bf.ReadBytes(128)))
|
||||
m.Description = stringsupport.SJISToUTF8Lossy(bfutil.UpToNull(bf.ReadBytes(256)))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func (m *MsgMhfCreateGuild) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Client
|
||||
m.AckHandle = bf.ReadUint32()
|
||||
bf.ReadUint16() // Zeroed
|
||||
bf.ReadUint16() // Name length
|
||||
m.Name, _ = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
m.Name = stringsupport.SJISToUTF8Lossy(bf.ReadNullTerminatedBytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ func (m *MsgMhfCreateJoint) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Client
|
||||
m.GuildID = bf.ReadUint32()
|
||||
bf.ReadUint16() // Zeroed
|
||||
bf.ReadUint16() // Name length
|
||||
m.Name, _ = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
m.Name = stringsupport.SJISToUTF8Lossy(bf.ReadNullTerminatedBytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func (m *MsgMhfEnumerateHouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cli
|
||||
bf.ReadUint16() // Zeroed
|
||||
lenName := bf.ReadUint8()
|
||||
if lenName > 0 {
|
||||
m.Name, _ = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
m.Name = stringsupport.SJISToUTF8Lossy(bf.ReadNullTerminatedBytes())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (m *MsgMhfLoadHouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientCo
|
||||
m.CheckPass = bf.ReadBool()
|
||||
bf.ReadUint16() // Zeroed
|
||||
bf.ReadUint8() // Password length
|
||||
m.Password, _ = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
m.Password = stringsupport.SJISToUTF8Lossy(bf.ReadNullTerminatedBytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func (m *MsgMhfOperateWarehouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.C
|
||||
lenName := bf.ReadUint8()
|
||||
bf.ReadUint16() // Zeroed
|
||||
if lenName > 0 {
|
||||
m.Name, _ = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
m.Name = stringsupport.SJISToUTF8Lossy(bf.ReadNullTerminatedBytes())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ func (m *MsgMhfSendMail) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientCon
|
||||
bf.ReadUint16() // Zeroed
|
||||
m.Quantity = bf.ReadUint16()
|
||||
m.ItemID = bf.ReadUint16()
|
||||
m.Subject, _ = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
m.Body, _ = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
m.Subject = stringsupport.SJISToUTF8Lossy(bf.ReadNullTerminatedBytes())
|
||||
m.Body = stringsupport.SJISToUTF8Lossy(bf.ReadNullTerminatedBytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ func (m *MsgMhfUpdateGuildMessageBoard) Parse(bf *byteframe.ByteFrame, ctx *clie
|
||||
m.StampID = bf.ReadUint32()
|
||||
m.TitleLength = bf.ReadUint32()
|
||||
m.BodyLength = bf.ReadUint32()
|
||||
m.Title, _ = stringsupport.SJISToUTF8(bf.ReadBytes(uint(m.TitleLength)))
|
||||
m.Body, _ = stringsupport.SJISToUTF8(bf.ReadBytes(uint(m.BodyLength)))
|
||||
m.Title = stringsupport.SJISToUTF8Lossy(bf.ReadBytes(uint(m.TitleLength)))
|
||||
m.Body = stringsupport.SJISToUTF8Lossy(bf.ReadBytes(uint(m.BodyLength)))
|
||||
case 1:
|
||||
m.PostID = bf.ReadUint32()
|
||||
case 2:
|
||||
@@ -47,8 +47,8 @@ func (m *MsgMhfUpdateGuildMessageBoard) Parse(bf *byteframe.ByteFrame, ctx *clie
|
||||
bf.ReadBytes(8)
|
||||
m.TitleLength = bf.ReadUint32()
|
||||
m.BodyLength = bf.ReadUint32()
|
||||
m.Title, _ = stringsupport.SJISToUTF8(bf.ReadBytes(uint(m.TitleLength)))
|
||||
m.Body, _ = stringsupport.SJISToUTF8(bf.ReadBytes(uint(m.BodyLength)))
|
||||
m.Title = stringsupport.SJISToUTF8Lossy(bf.ReadBytes(uint(m.TitleLength)))
|
||||
m.Body = stringsupport.SJISToUTF8Lossy(bf.ReadBytes(uint(m.BodyLength)))
|
||||
case 3:
|
||||
m.PostID = bf.ReadUint32()
|
||||
bf.ReadBytes(8)
|
||||
|
||||
@@ -30,7 +30,7 @@ func (m *MsgMhfUpdateHouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Client
|
||||
bf.ReadUint8() // Zeroed
|
||||
bf.ReadUint8() // Zeroed
|
||||
bf.ReadUint8() // Password length
|
||||
m.Password, _ = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
m.Password = stringsupport.SJISToUTF8Lossy(bf.ReadNullTerminatedBytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user