Skip to content

Commit c678b8e

Browse files
authored
Merge pull request #995 from GwtMaterialDesign/release_2.4.2
(Security Fixes) Fixed XSS Vulnerability and Bump junit from 4.12 to 4.13.1
2 parents a12ce54 + 230b8b0 commit c678b8e

29 files changed

+542
-52
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cache:
88
- $HOME/.m2
99
before_install:
1010
# install the gwt-material-jquery because it will depends on built in jquery
11-
- git clone -b release_2.4.1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
11+
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
1212
- cd gwt-material-jquery
1313
- mvn install -DskipTests=true -DdryRun=true
1414
- cd ..

.utility/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -ev
3-
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.4.1" ]; then
3+
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.4.2" ]; then
44
echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
55
mvn deploy -DskipTests --settings ~/settings.xml
66
fi

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs
2020

2121

2222
## Maven
23-
### Current Version 2.4.1
23+
### Current Version 2.4.2
2424
```xml
2525
<dependency>
2626
<groupId>com.github.gwtmaterialdesign</groupId>
2727
<artifactId>gwt-material</artifactId>
28-
<version>2.4.1</version>
28+
<version>2.4.2</version>
2929
</dependency>
3030
```
3131
### Snapshot Version 2.5.0-SNAPSHOT

gwt-material/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>gwt-material-parent</artifactId>
66
<groupId>com.github.gwtmaterialdesign</groupId>
7-
<version>2.4.1</version>
7+
<version>2.4.2</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010

gwt-material/src/main/java/gwt/material/design/client/base/AbstractButton.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import com.google.gwt.event.logical.shared.ValueChangeEvent;
2525
import com.google.gwt.event.logical.shared.ValueChangeHandler;
2626
import com.google.gwt.event.shared.HandlerRegistration;
27+
import com.google.gwt.safehtml.shared.HtmlSanitizer;
28+
import com.google.gwt.safehtml.shared.SafeHtml;
2729
import com.google.gwt.user.client.History;
2830
import com.google.gwt.user.client.ui.HasValue;
2931
import gwt.material.design.client.base.mixin.ActivatesMixin;
@@ -36,7 +38,7 @@
3638
* @author Ben Dol
3739
*/
3840
public abstract class AbstractButton extends MaterialWidget implements HasHref, HasGrid, HasActivates,
39-
HasTargetHistoryToken, HasType<ButtonType>, HasValue<String> {
41+
HasTargetHistoryToken, HasType<ButtonType>, HasValue<String>, HasSafeText {
4042

4143
private String targetHistoryToken;
4244
private Span span = new Span();
@@ -169,6 +171,21 @@ public void setText(String text) {
169171
}
170172
}
171173

174+
@Override
175+
public void setHtml(SafeHtml html) {
176+
span.setHtml(html);
177+
}
178+
179+
@Override
180+
public void setSanitizer(HtmlSanitizer sanitizer) {
181+
span.setSanitizer(sanitizer);
182+
}
183+
184+
@Override
185+
public HtmlSanitizer getSanitizer() {
186+
return span.getSanitizer();
187+
}
188+
172189
/**
173190
* Set the target history token for the widget. Note, that you should use either
174191
* {@link #setTargetHistoryToken(String)} or {@link #setHref(String)}, but not both as

gwt-material/src/main/java/gwt/material/design/client/base/AbstractValueWidget.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ public void setValue(V value, boolean fireEvents, boolean reload) {
8686
}
8787
}
8888

89-
//TODO:
90-
//setSanitizer();
91-
9289
@Override
9390
public void setErrorText(String errorText) {
9491
getStatusTextMixin().setErrorText(errorText);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2020 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.client.base;
21+
22+
import com.google.gwt.safehtml.shared.HtmlSanitizer;
23+
import com.google.gwt.safehtml.shared.SafeHtml;
24+
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
25+
26+
/**
27+
* HTML-escapes its argument and returns the result wrapped as a SafeHtml.
28+
*/
29+
public class DefaultHtmlSanitizer implements HtmlSanitizer {
30+
31+
@Override
32+
public SafeHtml sanitize(String html) {
33+
return SafeHtmlUtils.fromString(html);
34+
}
35+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2020 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.client.base;
21+
22+
import com.google.gwt.safehtml.shared.HtmlSanitizer;
23+
import com.google.gwt.safehtml.shared.SafeHtml;
24+
25+
public interface HasSafeText {
26+
27+
void setHtml(SafeHtml html);
28+
29+
void setSanitizer(HtmlSanitizer sanitizer);
30+
31+
HtmlSanitizer getSanitizer();
32+
}

gwt-material/src/main/java/gwt/material/design/client/base/TextWidget.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
package gwt.material.design.client.base;
2121

2222
import com.google.gwt.dom.client.Element;
23+
import com.google.gwt.safehtml.shared.HtmlSanitizer;
24+
import com.google.gwt.safehtml.shared.SafeHtml;
2325
import com.google.gwt.user.client.DOM;
2426
import com.google.gwt.user.client.ui.HasText;
2527
import gwt.material.design.client.base.mixin.TextMixin;
2628

27-
public class TextWidget extends MaterialWidget implements HasText {
29+
public class TextWidget extends MaterialWidget implements HasSafeText, HasText {
2830

29-
private final TextMixin<TextWidget> textMixin = new TextMixin<>(this);
31+
private TextMixin<TextWidget> textMixin;
3032

3133
public TextWidget() {
3234
super(DOM.createDiv());
@@ -42,11 +44,33 @@ public TextWidget(Element element, String... initialClass) {
4244

4345
@Override
4446
public String getText() {
45-
return textMixin.getText();
47+
return getTextMixin().getText();
4648
}
4749

4850
@Override
4951
public void setText(String text) {
50-
textMixin.setText(text);
52+
getTextMixin().setText(text);
5153
}
52-
}
54+
55+
@Override
56+
public void setHtml(SafeHtml html) {
57+
getTextMixin().setHtml(html);
58+
}
59+
60+
@Override
61+
public void setSanitizer(HtmlSanitizer sanitizer) {
62+
getTextMixin().setSanitizer(sanitizer);
63+
}
64+
65+
@Override
66+
public HtmlSanitizer getSanitizer() {
67+
return getTextMixin().getSanitizer();
68+
}
69+
70+
public TextMixin<TextWidget> getTextMixin() {
71+
if (textMixin == null) {
72+
textMixin = new TextMixin<>(this);
73+
}
74+
return textMixin;
75+
}
76+
}

gwt-material/src/main/java/gwt/material/design/client/base/mixin/AbstractMixin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* @author Sven Jacobs
2828
*/
29-
abstract class AbstractMixin<T extends UIObject> {
29+
public abstract class AbstractMixin<T extends UIObject> {
3030

3131
T uiObject;
3232

@@ -37,4 +37,8 @@ abstract class AbstractMixin<T extends UIObject> {
3737
public void setUiObject(T uiObject) {
3838
this.uiObject = uiObject;
3939
}
40+
41+
public T getUiObject() {
42+
return uiObject;
43+
}
4044
}

0 commit comments

Comments
 (0)