ipfs / ipfs/specs

resolve relative symlinks server side on gateway

Open
#284 0 comments 1 reaction 0 assignees View on GitHub
need/triage
Dominant language
HTML
Stars
1.2k
Forks
247
Avg merge
5d 21h
Merged PRs (30d)
4

Description

When a unixfs symlink is hit, if the mode is file (not block or car), gateway should emulate nginx and apache, that means resolve the symlink server side and return whatever file is being pointed to.

This proposal only targets relative symlinks (I have no idea what should happen with absolute ones).

To resolve it mean, take the current base path (the path of the folder containing the symlink).
Add the symlink path, do a lexical simplification (remove `a/..` and `.` entries), and repeat the usual gateway process at that point.

Gateway MUST error if the lexical simplification errors (such as by a symlink having more `..` than how deep it is in the dag).

Gateway MUST support recursively doing that (symlinks pointing to other symlinks). It MUST support a depth of at least 32, and SHOULD raise an error if number gets too big.

For example take this tree:
```
CID
+ a
| +- symlink (../b/example)
+ b
+- example
```
Loading `CID/a/symlink` the gateway would need to send the content of `CID/b/example`.
Because
First it resolve `/a/symlink` see that it's a symlink applies the content to the base path `/a/../b/example`
And then do a lexical simplification `/b/example` and then send this path content.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.