Skip to content

Commit

Permalink
nonce parameter for Content Security Policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Julienng committed Apr 30, 2024
1 parent e352bda commit b2e1311
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/@react-aria/i18n/src/server.tsx
Expand Up @@ -19,7 +19,8 @@ type PackageLocalizedStrings = {

interface PackageLocalizationProviderProps {
locale: string,
strings: PackageLocalizedStrings
strings: PackageLocalizedStrings,
nonce?: string
}

/**
Expand All @@ -33,7 +34,7 @@ export function PackageLocalizationProvider(props: PackageLocalizationProviderPr
}

let {locale, strings} = props;
return <script dangerouslySetInnerHTML={{__html: getPackageLocalizationScript(locale, strings)}} />;
return <script nonce={props.nonce} dangerouslySetInnerHTML={{__html: getPackageLocalizationScript(locale, strings)}} />;
}

/**
Expand Down
7 changes: 4 additions & 3 deletions scripts/buildI18n.js
Expand Up @@ -69,9 +69,9 @@ export default PackageLocalizedStrings;

index += `});
function LocalizedStringProvider({locale, dictionary: dict = dictionary}) {
function LocalizedStringProvider({locale, dictionary: dict = dictionary, nonce}) {
let strings = dict.getStringsForLocale(locale);
return createElement(PackageLocalizationProvider, {locale, strings});
return createElement(PackageLocalizationProvider, {locale, strings, nonce});
}
function getLocalizationScript(locale, dict = dictionary) {
Expand Down Expand Up @@ -126,7 +126,8 @@ import type {LocalizedStringDictionary} from '@internationalized/string';
interface LocalizedStringProviderProps {
locale: string,
dictionary?: LocalizedStringDictionary
dictionary?: LocalizedStringDictionary,
nonce?: string
}
export declare function LocalizedStringProvider(props: LocalizedStringProviderProps): React.JSX.Element;
Expand Down

0 comments on commit b2e1311

Please sign in to comment.