Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: script 标签中内容被转义 #12326

Open
wants to merge 1 commit into
base: feature/new-unio-ssr
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/preset-umi/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ umi build --clean
MetadataLoaderOmitKeys.Meta,
]) as Omit<
typeof args,
MetadataLoaderOmitKeys.Title & MetadataLoaderOmitKeys.Meta
MetadataLoaderOmitKeys.Title | MetadataLoaderOmitKeys.Meta
>)
: args;
const finalMarkUpArgs = {
Expand Down
8 changes: 5 additions & 3 deletions packages/renderer-react/src/html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ const HydrateMetadata = (props: IHtmlProps) => {
{htmlPageOpts?.headScripts?.map((script: IScript, key: number) => {
const { content, ...rest } = normalizeScripts(script);
return (
<script key={key} {...(rest as any)}>
{content}
</script>
<script
key={key}
{...(rest as any)}
dangerouslySetInnerHTML={{ __html: content }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

必须要用这个 dangerouslySetInnerHTML 吗,感觉有点怪怪的。

一个 SPA 为主的框架,更多人都是使用的 SPA 模式,不应该把 SSR 才可能涉及到的 dangerouslySetInnerHTML 混杂在产物里,目测这导致可能有的公司自动安全策略扫描过不去。

/>
);
})}
</>
Expand Down
Loading