From af17420be58fb233e88ecde802d36bef6bfacb5b Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 11 May 2023 11:01:21 +0200 Subject: [PATCH] SEBSERV-444 fixed --- .../seb/sebserver/gui/content/exam/LmsSetupForm.java | 3 ++- .../gui/service/i18n/impl/PolyglotPageServiceImpl.java | 10 +++++++++- .../java/ch/ethz/seb/sebserver/gui/widget/Message.java | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/LmsSetupForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/LmsSetupForm.java index fcac8ab8..a980c810 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/LmsSetupForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/LmsSetupForm.java @@ -15,6 +15,7 @@ import java.util.function.BooleanSupplier; import java.util.function.Function; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; @@ -481,7 +482,7 @@ public class LmsSetupForm implements TemplateComposer { case TOKEN_REQUEST: { throw new PageMessageException(new LocTextKey( "sebserver.lmssetup.action.test.tokenRequestError", - Utils.formatHTMLLinesForceEscaped(Utils.escapeHTML_XML_EcmaScript(error.message)))); + Utils.formatHTMLLinesForceEscaped(StringEscapeUtils.escapeHtml4(error.message)))); } case QUIZ_ACCESS_API_REQUEST: { if (error.message.contains("quizaccess_sebserver_get_exams")) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/i18n/impl/PolyglotPageServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/i18n/impl/PolyglotPageServiceImpl.java index 1ddf4989..c642653e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/i18n/impl/PolyglotPageServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/i18n/impl/PolyglotPageServiceImpl.java @@ -11,7 +11,9 @@ package ch.ethz.seb.sebserver.gui.service.i18n.impl; import java.util.Locale; import java.util.function.Consumer; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; import org.eclipse.rap.rwt.RWT; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; @@ -269,8 +271,14 @@ public final class PolyglotPageServiceImpl implements PolyglotPageService { final I18nSupport i18nSupport) { return label -> { + if (locTextKey != null) { - label.setText(i18nSupport.getText(locTextKey)); + final String text = i18nSupport.getText(locTextKey); + if (BooleanUtils.toBoolean((Boolean) label.getData(RWT.MARKUP_ENABLED))) { + label.setText(StringEscapeUtils.escapeHtml4(text)); + } else { + label.setText(text); + } } if (i18nSupport.hasText(locToolTipKey)) { label.setToolTipText(Utils.formatLineBreaks(i18nSupport.getText(locToolTipKey))); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java index df09b0f0..9913deec 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java @@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.gui.widget; import java.util.Locale; +import org.apache.commons.text.StringEscapeUtils; import org.eclipse.rap.rwt.RWT; import org.eclipse.rap.rwt.widgets.DialogCallback; import org.eclipse.swt.graphics.Rectangle; @@ -17,7 +18,6 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; -import ch.ethz.seb.sebserver.gbl.util.Utils; import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport; import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant; @@ -46,7 +46,7 @@ public final class Message extends MessageBox { super.prepareOpen(); } catch (final IllegalArgumentException e) { // fallback on markup text error - super.setMessage(Utils.escapeHTML_XML_EcmaScript(super.getMessage())); + super.setMessage(StringEscapeUtils.escapeHtml4(super.getMessage())); super.prepareOpen(); } final GridLayout layout = (GridLayout) super.shell.getLayout();