Skip to content

Commit fb0e1bf

Browse files
committed
Enduser: ensure to sanitize notification message
1 parent 09d1117 commit fb0e1bf

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

client/idrepo/common-ui/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ under the License.
113113
<groupId>org.apache.pdfbox</groupId>
114114
<artifactId>pdfbox</artifactId>
115115
</dependency>
116-
116+
117+
<dependency>
118+
<groupId>org.apache.commons</groupId>
119+
<artifactId>commons-text</artifactId>
120+
</dependency>
121+
117122
<dependency>
118123
<groupId>org.apache.syncope.common.keymaster</groupId>
119124
<artifactId>syncope-common-keymaster-client-api</artifactId>

client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/BaseLogin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.stream.Collectors;
2828
import javax.ws.rs.core.HttpHeaders;
2929
import org.apache.commons.lang3.StringUtils;
30+
import org.apache.commons.text.StringEscapeUtils;
3031
import org.apache.syncope.client.ui.commons.panels.BaseSSOLoginFormPanel;
3132
import org.apache.syncope.client.ui.commons.panels.NotificationPanel;
3233
import org.apache.syncope.common.keymaster.client.api.DomainOps;
@@ -209,7 +210,7 @@ public void renderHead(final IHeaderResponse response) {
209210

210211
if (StringUtils.isNotBlank(notificationMessage)) {
211212
response.render(OnLoadHeaderItem.forScript(StyledNotificationBehavior.jQueryShow(
212-
notificationMessage,
213+
StringEscapeUtils.escapeEcmaScript(notificationMessage),
213214
String.format("jQuery('#%s').data('kendoNotification')",
214215
notificationPanel.getNotificationMarkupId()),
215216
notificationLevel)));

client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/StyledNotificationBehavior.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,25 @@ public StyledNotificationBehavior(final String selector, final Options options)
3939
@Override
4040
public void show(final IPartialPageRequestHandler handler, final Serializable message, final String level) {
4141
if (handler != null) {
42-
handler.appendJavaScript(jQueryShow(this.format(String.valueOf(message), level), this.widget(), level));
42+
handler.appendJavaScript(jQueryShow(format(String.valueOf(message), level), widget(), level));
4343
}
4444
}
4545

4646
public static String jQueryShow(final CharSequence message, final String widget, final String level) {
47+
String actual = Notification.INFO.equalsIgnoreCase(level)
48+
? Notification.INFO
49+
: Notification.SUCCESS.equalsIgnoreCase(level)
50+
? Notification.SUCCESS
51+
: Notification.ERROR.equalsIgnoreCase(level)
52+
? Notification.ERROR
53+
: Notification.WARNING;
54+
4755
return String.format("%s.options.autoHideAfter = %s; %s.show( { message: '%s' } , '%s');",
4856
widget,
49-
Notification.SUCCESS.equalsIgnoreCase(level) || Notification.INFO.equalsIgnoreCase(level)
57+
Notification.SUCCESS.equals(actual) || Notification.INFO.equals(actual)
5058
? AUTOHIDEAFTER_GOOD : AUTOHIDEAFTER_BAD,
5159
widget,
5260
message,
53-
level.toLowerCase());
61+
actual);
5462
}
5563
}

0 commit comments

Comments
 (0)