~ivilata/gwit-spec

65888e5c516002a30ac785117b0d84a6802326fb — Ivan Vilata-i-Balaguer 4 months ago 05c96d6
Make URI retrieval fail if site config file exists & fails to parse.

Not finding the file should be ok (empty configuration), but a bad
configuration should not be discarded silently, otherwise a commit breaking
the configuration file would result in e.g. clients silently changing the root
directory to the top directory on URI retrieval.
1 files changed, 1 insertions(+), 1 deletions(-)

M README.md
M README.md => README.md +1 -1
@@ 339,7 339,7 @@ Once the client has established the value of `<COMMIT>`, it MUST check that `<CO

The client MUST then resolve the path `<PATH>` in the URI (which has already been percent-decoded if necessary) to a file or directory in the Git tree associated with the commit `<COMMIT>`, by following the steps below, so as to produce some output:

1. Try to parse `_gwit/self.ini` in the desired commit `<COMMIT>` (e.g. `git cat-file blob <COMMIT>:_gwit/self.ini | git config -f- …`); if that fails, treat site configuration as empty for the next steps.
1. If `_gwit/self.ini` exists as a file (blob) in the desired commit `<COMMIT>` (e.g. `git ls-tree --format='%(objecttype) %(objectname)' <COMMIT> _gwit/self.init` succeeds and reports `blob <CONF-FILE-HASH>`), parse it (e.g. `git cat-file blob <CONF-FILE-HASH> | git config -f- …`). If it does not exist, treat site configuration as empty for the next steps.
2. Compute `<RELPATH>` by replacing repetitions of the forward slash (`/`) in `<PATH>` by a single slash, then removing leading and trailing slashes, then removing dot segments according to the `remove_dot_segments` algorithm described in Section 5.2.4 of RFC3986 (e.g. `/foo//../bar/` becomes `bar`).

   The resulting `<RELPATH>` is relative to the site's root directory `<ROOT>` (as per site configuration) and either empty (meaning `<ROOT>` itself), or it consists of one or more non-empty path components separated by a single slash (for other files or directories).