Skip to content

Spec non-compliance inconsistency in URI parsing #306

@Insomniak47

Description

@Insomniak47

Hey all,

Back again, it seems like the following lines from /src/uri/mod.rs are non-spec compliant:

//855 in my branch, around there in master. 

    if scheme.is_none() {
        if authority_end != s.len() {
            return Err(ErrorKind::InvalidFormat.into());
        }

        let authority = Authority {
            data: unsafe { ByteStr::from_utf8_unchecked(s) },
        };

        return Ok(Uri {
            scheme: scheme.into(),
            authority: authority,
            path_and_query: PathAndQuery::empty(),
        });
    }

which makes sense because the spec isn't necessarily ergonomic in this case. It seems though if you're going to deviate from spec it should be a bit more consistent.

the table at:
https://tools.ietf.org/html/rfc3986#section-5.4.1

Indicates that with no scheme this would really be a relative path. Given that basically nobody would interpret it this way I can understand the desire to handle it as an authority though I don't see why you'd require that is exclusively an authority.

in "test_authority_uri_parts_round_trip" hyper.rs is parsed and round tripped. It seems odd to return an error on parsing if instead it was hyper.rs/somethingelse. I can put in the fix I just want to make sure everybody is on the same page re: ergonomics/implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions