Skip to content

Commit

Permalink
MOBILE-3947 chore: Allow inner HTML templates
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Nov 28, 2023
1 parent 1405675 commit 154a192
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/login/pages/site/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 9 additions & 3 deletions src/core/services/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 154a192

Please sign in to comment.