From f4baa241257350654aa441b1963e3b0761bbc51d Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Wed, 4 Dec 2024 04:52:12 +0000 Subject: [PATCH] Fix in Replays Apparently Caja CSS isn't loaded in Replays? Bypassed that dependency for . --- play.pokemonshowdown.com/src/battle-log.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/play.pokemonshowdown.com/src/battle-log.ts b/play.pokemonshowdown.com/src/battle-log.ts index c078c16a42..44edcd0e88 100644 --- a/play.pokemonshowdown.com/src/battle-log.ts +++ b/play.pokemonshowdown.com/src/battle-log.ts @@ -873,6 +873,8 @@ export class BattleLog { let dataUri = ''; let targetReplace = false; + // if Caja CSS isn't loaded, we still trust CSS + let unsanitizedStyle = ''; if (tagName === 'a') { if (getAttrib('target') === 'replace') { @@ -982,14 +984,13 @@ export class BattleLog { if (iconType) { const className = getAttrib('class'); - const style = getAttrib('style'); if (iconType === 'pokemon') { setAttrib('class', 'picon' + (className ? ' ' + className : '')); - setAttrib('style', Dex.getPokemonIcon(iconValue) + (style ? '; ' + style : '')); + unsanitizedStyle = Dex.getPokemonIcon(iconValue); } else if (iconType === 'item') { setAttrib('class', 'itemicon' + (className ? ' ' + className : '')); - setAttrib('style', Dex.getItemIcon(iconValue) + (style ? '; ' + style : '')); + unsanitizedStyle = Dex.getItemIcon(iconValue); } else if (iconType === 'type') { tagName = Dex.getTypeIcon(iconValue).slice(1, -3); } else if (iconType === 'category') { @@ -1002,6 +1003,10 @@ export class BattleLog { if (urlData.scheme_ === 'geo' || urlData.scheme_ === 'sms' || urlData.scheme_ === 'tel') return null; return urlData; }); + if (unsanitizedStyle) { + const style = getAttrib('style'); + setAttrib('style', unsanitizedStyle + (style ? '; ' + style : '')); + } if (dataUri && tagName === 'img') { setAttrib('src', dataUri);