Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

FQN: Add support for special characters #199

Merged
merged 1 commit into from
Aug 17, 2021

Conversation

hojberg
Copy link
Member

@hojberg hojberg commented Aug 16, 2021

Overview

  • Support special characters in FQNs like "." and "/" and correctly parse
    them from the URL using URL encoding and a special Unison specific
    encoding with ";." for ".".
  • Also update the namespace/definition url separator from "/-/" to "/;/".
  • Add a bunch of parser test coverage.

This fixes #196

* Support special characters in FQNs like "." and "/" and correctly parse
  them from the URL using URL encoding and a special Unison specific
  encoding with ";." for ".".
* Also update the namespace/definition url separator from "/-/" to "/;/".
* Add a bunch of parser test coverage.
@hojberg hojberg requested a review from pchiusano August 16, 2021 16:20
go z

x :: y ->
x :: go y
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapted from the Haskell implementation

urlDecode s =
-- Let invalid % encoding fall through, since it then must be valid
-- strings
Maybe.withDefault s (Url.percentDecode s)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

percentDecode seems a bit strange to me in that it fails if it encounters a % not followed by valid encoding characters. That kind of configuration are still valid URLs though.

@@ -161,7 +161,7 @@ hashQualifiedFromString sep str =

name_ :: unprefixedHash :: [] ->
Hash.fromString (Hash.prefix ++ unprefixedHash)
|> Maybe.map (HashQualified (FQN.fromString name_))
|> Maybe.map (HashQualified (toFQN name_))
Copy link
Member Author

@hojberg hojberg Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug; we were never passing this through a URL encoder.

-- ';' as the separator character between namespace FQNs and
-- definition FQNs. (';' is not a valid character in FQNs and is
-- safe as a separator/escape character).
[ b (succeed (identity ".") |. s ";.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this special case here didn't feel great, but was the simplest when chomping deals with character to character which would lead to a clash with /;/ (the namespace/definition separator).

@hojberg
Copy link
Member Author

hojberg commented Aug 17, 2021

@pchiusano when you have a moment, i'd love your eyes on this :)

Copy link
Member

@pchiusano pchiusano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me but LMK if you were looking for an opinion on anything in particular.

@hojberg hojberg merged commit a10f587 into main Aug 17, 2021
@hojberg hojberg deleted the support-special-character-fqns branch August 17, 2021 14:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FQNs in URLs should be escaped
2 participants