Skip to content

Fix inconsistent URL encoding#1

Merged
kzantow merged 1 commit intomasterfrom
fix/segment-escaping
Aug 12, 2021
Merged

Fix inconsistent URL encoding#1
kzantow merged 1 commit intomasterfrom
fix/segment-escaping

Conversation

@kzantow
Copy link

@kzantow kzantow commented Aug 12, 2021

Fixes three issues with the encoding/decoding of strings:

  1. Namespace segments are escaped as paths instead of queries to match
    how they are unescaped.
  2. Subpath segments are escaped to match how they are unescaped.
  3. Names are unescaped to match how they are escaped.

A test is added to ensure this is enforced for all components requiring
encoding. Five tests cases failed previous to the change:

  1. unencoded_namespace_segment_is_encoded:
    expected pkg:type/name/spac e/name@version?key=value#sub/path
    to parse as pkg:type/name/spac%20e/name@version?key=value#sub/path
    but got pkg:type/name/spac+e/name@version?key=value#sub/path
  2. pre-encoded_namespace_segment_is_unchanged:
    expected pkg:type/name/spac%20e/name@version?key=value#sub/path
    to parse as pkg:type/name/spac%20e/name@version?key=value#sub/path
    but got pkg:type/name/spac+e/name@version?key=value#sub/path
  3. pre-encoded_name_is_unchanged:
    expected pkg:type/name/space/nam%20e@version?key=value#sub/path
    to parse as pkg:type/name/space/nam%20e@version?key=value#sub/path
    but got pkg:type/name/space/nam%2520e@version?key=value#sub/path
  4. unencoded_subpath_segment_is_encoded:
    expected pkg:type/name/space/name@version?key=value#sub/pat h
    to parse as pkg:type/name/space/name@version?key=value#sub/pat%20h
    but got pkg:type/name/space/name@version?key=value#sub/pat h
  5. pre-encoded_subpath_segment_is_unchanged:
    expected pkg:type/name/space/name@version?key=value#sub/pat%20h
    to parse as pkg:type/name/space/name@version?key=value#sub/pat%20h
    but got pkg:type/name/space/name@version?key=value#sub/pat h

Fixes three issues with the encoding/decoding of strings:
1. Namespace segments are escaped as paths instead of queries to match
   how they are unescaped.
2. Subpath segments are escaped to match how they are unescaped.
3. Names are unescaped to match how they are escaped.

A test is added to ensure this is enforced for all components requiring
encoding. Five tests cases failed previous to the change:
1. unencoded_namespace_segment_is_encoded:
   expected    pkg:type/name/spac e/name@version?key=value#sub/path
   to parse as pkg:type/name/spac%20e/name@version?key=value#sub/path
   but got     pkg:type/name/spac+e/name@version?key=value#sub/path
2. pre-encoded_namespace_segment_is_unchanged:
   expected    pkg:type/name/spac%20e/name@version?key=value#sub/path
   to parse as pkg:type/name/spac%20e/name@version?key=value#sub/path
   but got     pkg:type/name/spac+e/name@version?key=value#sub/path
3. pre-encoded_name_is_unchanged:
   expected    pkg:type/name/space/nam%20e@version?key=value#sub/path
   to parse as pkg:type/name/space/nam%20e@version?key=value#sub/path
   but got     pkg:type/name/space/nam%2520e@version?key=value#sub/path
4. unencoded_subpath_segment_is_encoded:
   expected    pkg:type/name/space/name@version?key=value#sub/pat h
   to parse as pkg:type/name/space/name@version?key=value#sub/pat%20h
   but got     pkg:type/name/space/name@version?key=value#sub/pat h
5. pre-encoded_subpath_segment_is_unchanged:
   expected    pkg:type/name/space/name@version?key=value#sub/pat%20h
   to parse as pkg:type/name/space/name@version?key=value#sub/pat%20h
   but got     pkg:type/name/space/name@version?key=value#sub/pat h

Signed-off-by: Keith Zantow <kzantow@gmail.com>
@kzantow kzantow force-pushed the fix/segment-escaping branch from 54a515a to 2921588 Compare August 12, 2021 18:52
@kzantow kzantow merged commit cba37d0 into master Aug 12, 2021
@kzantow kzantow deleted the fix/segment-escaping branch August 12, 2021 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants