001package org.galaxyproject.gxformat2.v19_09.utils; 002 003import java.net.URI; 004 005public class DefaultFetcher implements Fetcher { 006 007 public String urlJoin(final String baseUrl, final String url) { 008 if (url.startsWith("_:")) { 009 return url; 010 } 011 012 final URI baseUri = Uris.toUri(baseUrl); 013 final URI uri = Uris.toUri(url); 014 if (baseUri.getScheme() != null 015 && !baseUri.getScheme().equals("file") 016 && "file".equals(uri.getScheme())) { 017 throw new ValidationException( 018 String.format( 019 "Not resolving potential remote exploit %s from base %s".format(url, baseUrl))); 020 } 021 String result = baseUri.resolve(uri).toString(); 022 if (result.startsWith("file:")) { 023 // Well this is gross - needed for http as well? 024 result = "file://" + result.substring("file:".length()); 025 } 026 return result; 027 } 028 029 public String fetchText(final String url) { 030 return "fetched"; 031 } 032}