import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
+import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
if (filename == null) {
return "app://APP/" + mapKey + "/";
} else {
- return "app://APP/" + mapKey + "/" + filename;
+ return "app://APP/" + mapKey + "/" + urlEncode(filename);
}
}
+ static String urlEncode(String filename) {
+ try {
+ return URLEncoder.encode(filename, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(
+ "UTF-8 charset not available (\"this should never happen\")",
+ e);
+ }
+ }
+
public boolean isApplicationResourceURL(URL context, String relativeUri) {
// If the relative uri is null, we are ready
if (relativeUri == null) {
if (filename == null) {
resourceURL.setResourceID("APP/" + mapKey + "/");
} else {
- resourceURL.setResourceID("APP/" + mapKey + "/" + filename);
+ resourceURL.setResourceID("APP/" + mapKey + "/"
+ + urlEncode(filename));
}
return resourceURL.toString();
} else {
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>LinkToPercentage</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">LinkToPercentage</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.link.LinkToPercentage?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestscomponentslinkLinkToPercentage::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLink[0]/domChild[0]@href</td>
+ <td>*/run/com.vaadin.tests.components.link.LinkToPercentage/APP/1/110%25+Vaadin</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
--- /dev/null
+package com.vaadin.tests.components.link;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import com.vaadin.terminal.ApplicationResource;
+import com.vaadin.terminal.StreamResource;
+import com.vaadin.terminal.StreamResource.StreamSource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Link;
+
+public class LinkToPercentage extends TestBase {
+
+ @Override
+ protected void setup() {
+ String filename = "110% Vaadin";
+ ApplicationResource resource = new StreamResource(new StreamSource() {
+ public InputStream getStream() {
+ return new InputStream() {
+ boolean first = true;
+
+ @Override
+ public int read() throws IOException {
+ if (first) {
+ first = false;
+ return 'a';
+ } else {
+ return -1;
+ }
+ }
+ };
+ }
+ }, filename, this);
+ addResource(resource);
+
+ Link link = new Link("The link", resource);
+
+ addComponent(link);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests using links with percentage signs in the address";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(5488);
+ }
+
+}