From 2e8634951a1d244491be9a86f452aa5fa785f6e0 Mon Sep 17 00:00:00 2001 From: Leszek Date: Wed, 16 Oct 2024 18:04:45 +0200 Subject: [PATCH] fix project header title serving old asset name --- .../components/header/headerTitleEditor.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/jsapp/js/components/header/headerTitleEditor.tsx b/jsapp/js/components/header/headerTitleEditor.tsx index 68c50d65bf..091626d5f8 100644 --- a/jsapp/js/components/header/headerTitleEditor.tsx +++ b/jsapp/js/components/header/headerTitleEditor.tsx @@ -36,7 +36,11 @@ class HeaderTitleEditor extends React.Component< } componentDidMount() { - this.unlisteners.push(assetStore.listen(this.onAssetLoad, this)); + // Note: there is a risk/vulnerability in this component connected to + // the usage of the `assetStore`. As `assetStore` is listening to + // `actions.resources.loadAsset` which is using our faulty `assetCache`, + // there is a chance `assetStore` would give us a cached (old) asset object. + this.unlisteners.push(assetStore.listen(this.onAssetStoreUpdated, this)); } componentWillUnmount() { @@ -45,11 +49,14 @@ class HeaderTitleEditor extends React.Component< }); } - onAssetLoad() { - this.setState({ - name: this.props.asset.name, - isPending: false, - }); + onAssetStoreUpdated() { + const foundAsset = assetStore.getAsset(this.props.asset.uid); + if (foundAsset) { + this.setState({ + name: foundAsset.name, + isPending: false, + }); + } } updateAssetTitle() {