Skip to content

Commit

Permalink
webdav: httptpc percent-decode local path
Browse files Browse the repository at this point in the history
Motivation:

Percent-encoding is a way of representing non-ASCII characters within a
URL.  Percent-encoding is always allowed and for certain characters (a
reserved character or a character with a reserved purpose used outside
of that purpose) it is required.  For example, the space character is
reserved and must always be escaped.

Currently, dCache will understand the local URL without expanding any
percent-encoded characters.

The following curl command illustrates an HTTP-TPC request where both
the source and destination URLs are precent-encoded.

```console
paul@celebrimbor:~$ curl -X COPY \
    -H "Credential: none" \
    -H "Authorization: Bearer $(oidc-token EGI-CHECKIN)" \
    -H "Source: https://prometheus.desy.de/Video/BlenderFoundation/Tears%20of%20steel.webm" \
    https://dcache-door-doma01.desy.de:2443/Users/paul/test%201.webm
```

This command will transfer the file `Tears of steel.webm` from the
remote, source server (prometheus.desy.de).  Howver, dCache will store
the transferred file as the file `test%201.webm` and not the desired
file `test 1.webm`.

Modification:

Use Java's URI class to parse the request URL and use this to extract
the target path.  This includes any required percent-encoded decoding.

Result:

dCache now supports HTTP-TPC transfers where the dCache-local path
includes HTTP reserved characters.

Target: master
Request: 9.2
Closes: #7512
Requires-notes: yes
Requires-book: no
Patch: https://rb.dcache.org/r/14239/
Acked-by: Tigran Mkrtchyan
  • Loading branch information
paulmillar authored and lemora committed Apr 2, 2024
1 parent e08dc2a commit 92c2350
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -387,8 +387,9 @@ private void processThirdPartyCopy(Request request, Response response)

TransferType type = TransferType.fromScheme(remote.getScheme());

var requestPath = URI.create(request.getAbsoluteUrl()).getPath();
FsPath path = _pathMapper.asDcachePath(ServletRequest.getRequest(),
request.getAbsolutePath(), m -> new ErrorResponseException(Status.SC_FORBIDDEN, m));
requestPath, m -> new ErrorResponseException(Status.SC_FORBIDDEN, m));

// Always check any client-supplied Overwrite header, to throw an error if the value is malformed.
boolean overwriteAllowed = clientAllowsOverwrite();
Expand Down

0 comments on commit 92c2350

Please sign in to comment.