diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2021-01-03 12:51:50 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-03 12:51:50 +0900 |
| commit | e74a47916dcd33ed2bd9d311c5bf7dd74c5564a9 (patch) | |
| tree | a7dbbeb909c2fe69bb83ba19bb0ee75159d4045c /src/client | |
| parent | チャンネルページから別チャンネルページに移動時にタ... (diff) | |
| download | misskey-e74a47916dcd33ed2bd9d311c5bf7dd74c5564a9.tar.gz misskey-e74a47916dcd33ed2bd9d311c5bf7dd74c5564a9.tar.bz2 misskey-e74a47916dcd33ed2bd9d311c5bf7dd74c5564a9.zip | |
Fix CSS injection at MFM speed (#7051)
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/components/mfm.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/client/components/mfm.ts b/src/client/components/mfm.ts index 1590e29142..bca469a159 100644 --- a/src/client/components/mfm.ts +++ b/src/client/components/mfm.ts @@ -48,6 +48,11 @@ export default defineComponent({ const ast = (this.plain ? parsePlain : parse)(this.text); + const validTime = (t: string | null | undefined) => { + if (t == null) return null; + return t.match(/^[0-9.]+s$/) ? t : null; + }; + const genEl = (ast: MfmForest) => concat(ast.map((token): VNode[] => { switch (token.node.type) { case 'text': { @@ -86,17 +91,17 @@ export default defineComponent({ break; } case 'jelly': { - const speed = token.node.props.args.speed || '1s'; + const speed = validTime(token.node.props.args.speed) || '1s'; style = (this.$store.state.animatedMfm ? `animation: mfm-rubberBand ${speed} linear infinite both;` : ''); break; } case 'twitch': { - const speed = token.node.props.args.speed || '0.5s'; + const speed = validTime(token.node.props.args.speed) || '0.5s'; style = this.$store.state.animatedMfm ? `animation: mfm-twitch ${speed} ease infinite;` : ''; break; } case 'shake': { - const speed = token.node.props.args.speed || '0.5s'; + const speed = validTime(token.node.props.args.speed) || '0.5s'; style = this.$store.state.animatedMfm ? `animation: mfm-shake ${speed} ease infinite;` : ''; break; } @@ -109,7 +114,7 @@ export default defineComponent({ token.node.props.args.x ? 'mfm-spinX' : token.node.props.args.y ? 'mfm-spinY' : 'mfm-spin'; - const speed = token.node.props.args.speed || '1.5s'; + const speed = validTime(token.node.props.args.speed) || '1.5s'; style = this.$store.state.animatedMfm ? `animation: ${anime} ${speed} linear infinite; animation-direction: ${direction};` : ''; break; } |