Skip to content

Commit

Permalink
Fix <psicon> in Replays
Browse files Browse the repository at this point in the history
Apparently Caja CSS isn't loaded in Replays? Bypassed that dependency
for <psicon>.
  • Loading branch information
Zarel committed Dec 4, 2024
1 parent 565a057 commit f4baa24
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions play.pokemonshowdown.com/src/battle-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,8 @@ export class BattleLog {

let dataUri = '';
let targetReplace = false;
// if Caja CSS isn't loaded, we still trust <psicon> CSS
let unsanitizedStyle = '';

if (tagName === 'a') {
if (getAttrib('target') === 'replace') {
Expand Down Expand Up @@ -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') {
Expand All @@ -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);
Expand Down

0 comments on commit f4baa24

Please sign in to comment.