MOBILE-3947 chore: Allow inner HTML templates

main
Pau Ferrer Ocaña 2023-11-28 12:31:26 +01:00
parent 47d5eb5eaa
commit 2db3635882
3 changed files with 12 additions and 4 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -815,14 +815,20 @@ export class CoreDomUtilsProvider {
* @returns Promise resolved with the alert modal.
*/
async showAlertWithOptions(options: AlertOptions = {}, autocloseTime?: number): Promise<HTMLIonAlertElement> {
const hasHTMLTags = CoreTextUtils.hasHTMLTags(<string> 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(<string> options.message);
message = await CoreLang.filterMultilang(message);
}
const alertId = <string> 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.