import java.io.IOException;
import java.net.URI;
+import java.net.URL;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import eu.etaxonomy.cdm.common.UrlUtf8Coder;
import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
protected URI getParsedText() throws Exception {
String uriText = super.getText();
if(uriText!=null){
- return new URI(super.getText());
+ try{
+ return new URI(super.getText());
+ }catch(Exception e){
+ URL url = new URL(uriText);
+ String[] pathElements = url.getPath().split("/");
+
+ for (String element: pathElements){
+ String replacement = UrlUtf8Coder.encode(element);
+ uriText = uriText.replace(element, replacement);
+ }
+ if (url.getQuery() != null){
+ uriText = uriText.replace(url.getQuery(), UrlUtf8Coder.encode(url.getQuery()));
+ }
+ url = new URL(uriText);
+ return url.toURI();
+
+ }
+
}
return null;
}