Skip to content

Commit

Permalink
SEBSERV-444 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed May 11, 2023
1 parent 5612016 commit af17420
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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;
Expand Down Expand Up @@ -481,7 +482,7 @@ private static PageAction handleTestResult(
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")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
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;
Expand Down Expand Up @@ -269,8 +271,14 @@ private static Consumer<Label> labelFunction(
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)));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

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;
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;

Expand Down Expand Up @@ -46,7 +46,7 @@ protected void prepareOpen() {
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();
Expand Down

0 comments on commit af17420

Please sign in to comment.