From: Ian Jackson Date: Tue, 16 Mar 2021 13:18:46 +0000 (+0000) Subject: hidden: Fix descriptions in log messages to not leak X-Git-Tag: otter-0.4.0~9 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e4877978e53effc27826344759c6a451b80c7c60;p=otter.git hidden: Fix descriptions in log messages to not leak Signed-off-by: Ian Jackson --- diff --git a/src/updates.rs b/src/updates.rs index e73235b2..4cd380ab 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -202,21 +202,30 @@ struct FormattedLogEntry<'u> { #[throws(OE)] pub fn log_did_to_piece_whoby( ioccults: &IOccults, - occults: &GameOccults, - player: PlayerId, - gpl: &mut GPlayer, - piece: PieceId, gpc: &GPiece, ipc: &IPiece, + _occults: &GameOccults, + _player: PlayerId, + by_gpl: &mut GPlayer, + _piece: PieceId, + gpc: &GPiece, ipc: &IPiece, did: &str, ) -> (Vec, Option) { - let who_by = Html(htmlescape::encode_minimal(&gpl.nick)); - let pri = piece_pri(ioccults, occults, player, gpl, piece, gpc, ipc) - .ok_or(OE::PieceGone)?; + let who_by = Html(htmlescape::encode_minimal(&by_gpl.nick)); + let y = gpc.fully_visible_to_everyone(); + let desc = (||{ + Ok::<_,IE>(match ipc.show_or_instead(ioccults, y)? { + Left(y) => ipc.show(y).describe_html(gpc)?, + Right(instead) => instead.describe_html()?, + }) + })().unwrap_or_else(|e|{ + error!("failed to format during logging: {:?}", e); + Html::lit("") + }); let log = vec![ LogEntry { html: Html(format!( "{} {} {}", &who_by.0, did, - pri.describe(ioccults, gpc, ipc).0, + desc.0, ))}]; (log, Some(who_by)) } @@ -226,11 +235,11 @@ pub fn log_did_to_piece( ioccults: &IOccults, occults: &GameOccults, player: PlayerId, - gpl: &mut GPlayer, + by_gpl: &mut GPlayer, piece: PieceId, gpc: &GPiece, ipc: &IPiece, did: &str, ) -> Vec { - log_did_to_piece_whoby(ioccults,occults,player,gpl,piece,gpc,ipc,did)?.0 + log_did_to_piece_whoby(ioccults,occults,player,by_gpl,piece,gpc,ipc,did)?.0 } // ---------- prepared updates, queued in memory ----------