You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Andrew Schwartzmeyer <an...@schwartzmeyer.com> on 2017/08/15 18:04:42 UTC

Re: Review Request 60622: Add new stout function: path::uri (convert filename to valid URI).

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60622/#review182967
-----------------------------------------------------------




3rdparty/stout/include/stout/path.hpp
Lines 68 (patched)
<https://reviews.apache.org/r/60622/#comment258936>

    I don't think I would use `bool addprefix` for this logic. A URI by definition is _required_ to have the scheme. In fact, as far as I can tell from the RFC, the scheme and the host are the only required parts of a URI:
    
         scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]
    
    So using this with `addprefix = false` would _not_ return a URI, and then the function no longer makes sense.
    
    What use case drove the additoin of `bool addprefix`, can we solve it in another way?



3rdparty/stout/include/stout/path.hpp
Lines 75 (patched)
<https://reviews.apache.org/r/60622/#comment258938>

    I don't like duplicating this logic. We should keep the shared logic common to one spot, and the platform-specific logic by itself.



3rdparty/stout/include/stout/path.hpp
Lines 77 (patched)
<https://reviews.apache.org/r/60622/#comment258940>

    If this is the case, what are we doing on Linux if the path has backslashes in it?
    
    I recognize this wasn't already previously handled, but it's a good question. Should this function be normalizing as well?


- Andrew Schwartzmeyer


On July 3, 2017, 12:30 p.m., Jeff Coffler wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60622/
> -----------------------------------------------------------
> 
> (Updated July 3, 2017, 12:30 p.m.)
> 
> 
> Review request for mesos, Andrew Schwartzmeyer, John Kordich, Joseph Wu, and Li Li.
> 
> 
> Bugs: MESOS-6705
>     https://issues.apache.org/jira/browse/MESOS-6705
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Add new stout function: path::uri (convert filename to valid URI).
> 
> 
> Diffs
> -----
> 
>   3rdparty/stout/include/stout/path.hpp 6ee3a44cd6a878fe383aa68df40b82857b93d0b4 
>   3rdparty/stout/tests/path_tests.cpp f8c14d5aefe0b49adb778da784143a328c96183d 
> 
> 
> Diff: https://reviews.apache.org/r/60622/diff/1/
> 
> 
> Testing
> -------
> 
> See upstream
> 
> 
> Thanks,
> 
> Jeff Coffler
> 
>


Re: Review Request 60622: Add new stout function: path::uri (convert filename to valid URI).

Posted by Joseph Wu <jo...@mesosphere.io>.

> On Aug. 15, 2017, 11:04 a.m., Andrew Schwartzmeyer wrote:
> > 3rdparty/stout/include/stout/path.hpp
> > Lines 68 (patched)
> > <https://reviews.apache.org/r/60622/diff/1/?file=1768697#file1768697line68>
> >
> >     I don't think I would use `bool addprefix` for this logic. A URI by definition is _required_ to have the scheme. In fact, as far as I can tell from the RFC, the scheme and the host are the only required parts of a URI:
> >     
> >          scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]
> >     
> >     So using this with `addprefix = false` would _not_ return a URI, and then the function no longer makes sense.
> >     
> >     What use case drove the additoin of `bool addprefix`, can we solve it in another way?

Paths and URIs are fundamentally different things.  So none of this backslash->slash replacement should be happening in the `Path` class.

(Consider how Python has `os.path.join` and `urlparse.urljoin`.)

I have some (incomplete) patches that add URI parsing to stout (See: https://reviews.apache.org/r/46588/diff/4#3 ).  We basically need a URI class (without parsing for now) with some of the same helpers in the `path.hpp` file; especially something akin to `uri::join`.


- Joseph


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60622/#review182967
-----------------------------------------------------------


On July 3, 2017, 12:30 p.m., Jeff Coffler wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60622/
> -----------------------------------------------------------
> 
> (Updated July 3, 2017, 12:30 p.m.)
> 
> 
> Review request for mesos, Andrew Schwartzmeyer, John Kordich, Joseph Wu, and Li Li.
> 
> 
> Bugs: MESOS-6705
>     https://issues.apache.org/jira/browse/MESOS-6705
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Add new stout function: path::uri (convert filename to valid URI).
> 
> 
> Diffs
> -----
> 
>   3rdparty/stout/include/stout/path.hpp 6ee3a44cd6a878fe383aa68df40b82857b93d0b4 
>   3rdparty/stout/tests/path_tests.cpp f8c14d5aefe0b49adb778da784143a328c96183d 
> 
> 
> Diff: https://reviews.apache.org/r/60622/diff/1/
> 
> 
> Testing
> -------
> 
> See upstream
> 
> 
> Thanks,
> 
> Jeff Coffler
> 
>


Re: Review Request 60622: Add new stout function: path::uri (convert filename to valid URI).

Posted by Jeff Coffler <je...@taltos.com>.

> On Aug. 15, 2017, 6:04 p.m., Andrew Schwartzmeyer wrote:
> > 3rdparty/stout/include/stout/path.hpp
> > Lines 77 (patched)
> > <https://reviews.apache.org/r/60622/diff/1/?file=1768697#file1768697line77>
> >
> >     If this is the case, what are we doing on Linux if the path has backslashes in it?
> >     
> >     I recognize this wasn't already previously handled, but it's a good question. Should this function be normalizing as well?

On Linux, backslashes are a valid part of the filename. We can't just "normalize" this was that makes the filename fundamentally different. You can percent-encode a URI to contain a '\' character, but then this would imply that we have a URI decode function, and today we don't have that in any common form.

This was always a problem on Linux - my changes don't affect that one way or the other. If this is a problem for customers, we should create a separate bug for this and fix it separately from these changes.


- Jeff


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60622/#review182967
-----------------------------------------------------------


On July 3, 2017, 7:30 p.m., Jeff Coffler wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60622/
> -----------------------------------------------------------
> 
> (Updated July 3, 2017, 7:30 p.m.)
> 
> 
> Review request for mesos, Andrew Schwartzmeyer, John Kordich, Joseph Wu, and Li Li.
> 
> 
> Bugs: MESOS-6705
>     https://issues.apache.org/jira/browse/MESOS-6705
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Add new stout function: path::uri (convert filename to valid URI).
> 
> 
> Diffs
> -----
> 
>   3rdparty/stout/include/stout/path.hpp 6ee3a44cd6a878fe383aa68df40b82857b93d0b4 
>   3rdparty/stout/tests/path_tests.cpp f8c14d5aefe0b49adb778da784143a328c96183d 
> 
> 
> Diff: https://reviews.apache.org/r/60622/diff/1/
> 
> 
> Testing
> -------
> 
> See upstream
> 
> 
> Thanks,
> 
> Jeff Coffler
> 
>