Skip to content

Commit

Permalink
bep: encode file paths in URI format
Browse files Browse the repository at this point in the history
We need to ensure that special characters are encoded according to the
URI specification RFC2396.

Change-Id: Ie93cbe11a70f448d2e7bacd0bba5699ec20cac25
PiperOrigin-RevId: 167301074
  • Loading branch information
buchgr authored and meteorcloudy committed Sep 4, 2017
1 parent 919d1b7 commit f5a0b38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
public interface PathConverter {
/**
* Return the URI corresponding to the given path, if the path can be converted to a URI by this
* path converter; return {@link null} otherwise.
* Returns a URI according to RFC2396 corresponding to the given path, if the path can be
* converted to a URI by this path converter; return {@code null} otherwise.
*/
String apply(Path path);
}
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ message File {
string name = 1;

oneof file {
// A location where the contents of the file can be found.
// A location where the contents of the file can be found. The string is
// encoded according to RFC2396.
string uri = 2;
// The contents of the file, if they are guaranteed to be short.
bytes contents = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.devtools.build.lib.buildeventstream.BuildEventTransport;
import com.google.devtools.build.lib.buildeventstream.PathConverter;
import com.google.devtools.build.lib.vfs.Path;
import java.io.File;
import java.io.IOException;

/** Factory used to create a Set of BuildEventTransports from BuildEventStreamOptions. */
Expand Down Expand Up @@ -101,7 +102,7 @@ protected abstract BuildEventTransport create(BuildEventStreamOptions options,
private static class NullPathConverter implements PathConverter {
@Override
public String apply(Path path) {
return "file://" + path;
return new File(path.getPathString()).toURI().toString();
}
}
}

0 comments on commit f5a0b38

Please sign in to comment.