xss 问题修复

This commit is contained in:
2betop 2020-12-09 13:20:54 +08:00
parent eb939b0e3f
commit 66a1f910b0

View File

@ -157,6 +157,13 @@ export default class IFrame extends React.Component<IFrameProps, object> {
...tempStyle, ...tempStyle,
...style ...style
}; };
const finalSrc = src ? buildApi(src, data).url : undefined;
if (typeof finalSrc === 'string' && /javascript\:/.test(finalSrc)) {
return <p> iframe </p>;
}
return ( return (
<iframe <iframe
className={className} className={className}
@ -164,7 +171,7 @@ export default class IFrame extends React.Component<IFrameProps, object> {
style={style} style={style}
ref={this.IFrameRef} ref={this.IFrameRef}
onLoad={this.onLoad} onLoad={this.onLoad}
src={src ? buildApi(src, data).url : undefined} src={finalSrc}
/> />
); );
} }