]> source.dussan.org Git - gitblit.git/commitdiff
Fixed Gravatar image security exception with Wicket 1.4.20
authorJames Moger <james.moger@gitblit.com>
Sun, 25 Mar 2012 22:01:59 +0000 (18:01 -0400)
committerJames Moger <james.moger@gitblit.com>
Sun, 25 Mar 2012 22:01:59 +0000 (18:01 -0400)
src/com/gitblit/wicket/ExternalImage.java [new file with mode: 0644]
src/com/gitblit/wicket/panels/GravatarImage.java

diff --git a/src/com/gitblit/wicket/ExternalImage.java b/src/com/gitblit/wicket/ExternalImage.java
new file mode 100644 (file)
index 0000000..3325774
--- /dev/null
@@ -0,0 +1,35 @@
+/*\r
+ * Copyright 2012 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.wicket;\r
+\r
+import org.apache.wicket.markup.ComponentTag;\r
+import org.apache.wicket.markup.html.WebComponent;\r
+import org.apache.wicket.model.Model;\r
+\r
+public class ExternalImage extends WebComponent {\r
+\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       public ExternalImage(String id, String url) {\r
+               super(id, new Model<String>(url));\r
+       }\r
+\r
+       protected void onComponentTag(ComponentTag tag) {\r
+               super.onComponentTag(tag);\r
+               checkComponentTag(tag, "img");\r
+               tag.put("src", getDefaultModelObjectAsString());\r
+       }\r
+}
\ No newline at end of file
index 0dc0502161890625ef168ac13cbfe14e2b79d7ff..b1c7b65c5c046ae6912b30849200a9649acf9db3 100644 (file)
@@ -17,19 +17,17 @@ package com.gitblit.wicket.panels;
 \r
 import java.text.MessageFormat;\r
 \r
-import org.apache.wicket.AttributeModifier;\r
 import org.apache.wicket.behavior.SimpleAttributeModifier;\r
-import org.apache.wicket.markup.html.image.Image;\r
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
 import org.apache.wicket.markup.html.link.Link;\r
 import org.apache.wicket.markup.html.panel.Panel;\r
-import org.apache.wicket.model.Model;\r
 import org.eclipse.jgit.lib.PersonIdent;\r
 \r
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.ActivityUtils;\r
 import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.ExternalImage;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.GravatarProfilePage;\r
 \r
@@ -56,8 +54,7 @@ public class GravatarImage extends Panel {
                                WicketUtils.newObjectParameter(hash));\r
                link.add(new SimpleAttributeModifier("target", "_blank"));\r
                String url = ActivityUtils.getGravatarThumbnailUrl(email, width);\r
-               Image image = new Image("image");\r
-               image.add(new AttributeModifier("src", true, new Model<String>(url)));\r
+               ExternalImage image = new ExternalImage("image", url);\r
                WicketUtils.setCssClass(image, "gravatar");\r
                link.add(image);\r
                WicketUtils.setHtmlTooltip(link,\r