Title: reserved characters are treated inconsistently and not sensibly preserved · Issue #16 · python-hyper/hyperlink · GitHub
Open Graph Title: reserved characters are treated inconsistently and not sensibly preserved · Issue #16 · python-hyper/hyperlink
X Title: reserved characters are treated inconsistently and not sensibly preserved · Issue #16 · python-hyper/hyperlink
Description: This has been a design flaw since the inception of the library, so, mea culpa on that. Fundamentally, preserving, escaping, and encoding "reserved" characters is entirely the URL object's job, and it's failing at that. Possibly the most ...
Open Graph Description: This has been a design flaw since the inception of the library, so, mea culpa on that. Fundamentally, preserving, escaping, and encoding "reserved" characters is entirely the URL object's job, and ...
X Description: This has been a design flaw since the inception of the library, so, mea culpa on that. Fundamentally, preserving, escaping, and encoding "reserved" characters is entirely the URL object...
Opengraph URL: https://github.com/python-hyper/hyperlink/issues/16
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"reserved characters are treated inconsistently and not sensibly preserved","articleBody":"This has been a design flaw since the inception of the library, so, mea culpa on that.\r\n\r\nFundamentally, preserving, escaping, and encoding \"reserved\" characters is entirely the URL object's job, and it's failing at that. Possibly the most succinct demonstration of the problem is this:\r\n\r\n```python\r\n>>> u = URL()\r\n>>> u = u.child(u'/')\r\n>>> u = u.asIRI()\r\nTraceback (most recent call last):\r\n File \"\u003cinput>\", line 1, in \u003cmodule>\r\n u = u.asIRI()\r\n File\r\n\"/Users/glyph/Library/Python/2.7/lib/python/site-packages/hyperlink/_url.py\",\r\nline 1116, in to_iri\r\n fragment=_percent_decode(self.fragment))\r\n File\r\n\"/Users/glyph/Library/Python/2.7/lib/python/site-packages/hyperlink/_url.py\",\r\nline 861, in replace\r\n userinfo=_optional(userinfo, self.userinfo),\r\n File\r\n\"/Users/glyph/Library/Python/2.7/lib/python/site-packages/hyperlink/_url.py\",\r\nline 606, in __init__\r\n for segment in path))\r\n File\r\n\"/Users/glyph/Library/Python/2.7/lib/python/site-packages/hyperlink/_url.py\",\r\nline 606, in \u003cgenexpr>\r\n for segment in path))\r\n File\r\n\"/Users/glyph/Library/Python/2.7/lib/python/site-packages/hyperlink/_url.py\",\r\nline 410, in _textcheck\r\n % (''.join(delims), name, value))\r\nValueError: one or more reserved delimiters /?# present in path segment: u'/'\r\n>>>\r\n```\r\n\r\nThis is - obviously I hope - the wrong place to be failing with an error like this.\r\n\r\nThere was previously *some* attempt to preserve these characters in the data model and escape them only upon stringification, but d26814c074c6f9787e62af907df17fbd68fde615 wrecked these semantics. (In fairness: the attempt to do this was broken, and there are some places, like the scheme, where certain characters indeed *cannot* be represented, so this direction isn't entirely wrong.)\r\n\r\nFundamentally if a user wants to encode slashes, question marks, hash signs or whatever else that a human might, for example, type into a text field, then it should be possible to do that.\r\n\r\nWe could fix this obvious manifestation of the problem by just putting back the escape-only-on-`asText` logic, but that still leaves an even more pernicious problem:\r\n\r\n```python\r\n>>> u = URL(path=tuple([u'%2525']))\r\n>>> u.asText()\r\nu'%2525'\r\n>>> u.asIRI().asText()\r\nu'%25'\r\n>>> u.asIRI().asIRI().asText()\r\nu'%'\r\n>>> \r\n```\r\n\r\nClearly, multiple trips through `asIRI` should not be un-escaping the escape character - the idea is that `.asIRI()` is a normalization step, that should be idempotent upon subsequent calls.\r\n\r\nFor the moment, I'm not sure exactly what the correct fix is here, but the property I'd really like to preserve is that for any `x`,\r\n\r\n`URL.fromText(URL().child(x).\u003cas many asIRI()s or asURI()s as you want>.asText()).\u003cas many .asIRI()s as you want, although possibly not .asURI()s>.segments[0] == x`\r\n","author":{"url":"https://github.com/glyph","@type":"Person","name":"glyph"},"datePublished":"2017-06-25T08:00:36Z","url":"https://github.com/python-hyper/hyperlink/issues/16"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1feb126f-b3c9-6aff-198b-22be9ff05e8a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B2C:37300:E1DF4E:13D1AF5:6B06F0A8 |
| html-safe-nonce | 4032811f3bcba483b08b1647b69db31ea95af203f6c8a0eba655dbbc6118b98b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjJDOjM3MzAwOkUxREY0RToxM0QxQUY1OjZCMDZGMEE4IiwidmlzaXRvcl9pZCI6IjgzMzkzMjQyMzk5MTY0OTUwMTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b583659b06bcd87d022b797d1ad0706c72c4d4cc70160e29c08a724e31ccc603 |
| hovercard-subject-tag | issue:238366753 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-hyper/hyperlink/16/issue_layout |
| twitter:image | https://opengraph.githubassets.com/120ea7c62b8ae4819ebe3b3bcd0fecd63f23b2391f4819a425a7b98384e03eb0/python-hyper/hyperlink/issues/16 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/120ea7c62b8ae4819ebe3b3bcd0fecd63f23b2391f4819a425a7b98384e03eb0/python-hyper/hyperlink/issues/16 |
| og:image:alt | This has been a design flaw since the inception of the library, so, mea culpa on that. Fundamentally, preserving, escaping, and encoding "reserved" characters is entirely the URL object's job, and ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | glyph |
| hostname | github.com |
| expected-hostname | github.com |
| None | 351ea5ca38a5758919d44ee52c70fe9003c0c2dfa20f04effd7fac0c5330c16b |
| turbo-cache-control | no-preview |
| go-import | github.com/python-hyper/hyperlink git https://github.com/python-hyper/hyperlink.git |
| octolytics-dimension-user_id | 13035907 |
| octolytics-dimension-user_login | python-hyper |
| octolytics-dimension-repository_id | 82321340 |
| octolytics-dimension-repository_nwo | python-hyper/hyperlink |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 82321340 |
| octolytics-dimension-repository_network_root_nwo | python-hyper/hyperlink |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 891bde3f438884e9c6c7ccd826f33805910a978b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width