diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b295b1723..d0a5dcfd4 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -52,6 +52,8 @@ export function createTranslateLoader(http: HttpClient): TranslateHttpLoader { IonicModule.forRoot( { navAnimation: moodleTransitionAnimation, + innerHTMLTemplatesEnabled: true, + sanitizerEnabled: true, }, ), HttpClientModule, // HttpClient is used to make JSON requests. It fails for HEAD requests because there is no content. diff --git a/src/core/features/login/pages/site/site.ts b/src/core/features/login/pages/site/site.ts index b85b1c865..cbca54a66 100644 --- a/src/core/features/login/pages/site/site.ts +++ b/src/core/features/login/pages/site/site.ts @@ -459,8 +459,8 @@ export class CoreLoginSitePage implements OnInit { }); if (errorDetails) { + // Avoid sanitizing JS. const containerElement = alertElement.querySelector('.core-error-info-container'); - if (containerElement) { containerElement.innerHTML = CoreErrorInfoComponent.render(errorDetails, errorCode); } diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index feae6ef72..d44738c6e 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -815,14 +815,20 @@ export class CoreDomUtilsProvider { * @returns Promise resolved with the alert modal. */ async showAlertWithOptions(options: AlertOptions = {}, autocloseTime?: number): Promise { - const hasHTMLTags = CoreTextUtils.hasHTMLTags( options.message || ''); + let message = typeof options.message == 'string' + ? options.message + : options.message?.value || ''; + + const hasHTMLTags = CoreTextUtils.hasHTMLTags(message); if (hasHTMLTags && !CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.7')) { // Treat multilang. - options.message = await CoreLang.filterMultilang( options.message); + message = await CoreLang.filterMultilang(message); } - const alertId = Md5.hashAsciiStr((options.header || '') + '#' + (options.message || '')); + options.message = message; + + const alertId = Md5.hashAsciiStr((options.header || '') + '#' + (message|| '')); if (this.displayedAlerts[alertId]) { // There's already an alert with the same message and title. Return it.