IceCubesApp/Packages/Models
Grant McSheffrey 30f9da06c8
Support status links with non-ASCII characters (Bugfix 1546) (#1550)
* Allow creation of URL objects from strings containing non-ASCII characters

Adds a new initializer for creating URL objects with a flag to specify that
non-ASCII characters found in the path or query string should first be
URL encoded.

* Add basic test for creating HTMLString objects

* Encode link paths and queries when parsing statuses

It's common to use non-ASCII characters in URLs even though they're technically
invalid characters. Every modern browser handles this by silently encoding
the invalid characters on the user's behalf. However, trying to create a URL
object with un-encoded characters will result in nil so we need to encode the
invalid characters before creating the URL object. The unencoded version
should still be shown in the displayed status.

The parsing of the URL string is a little messy because we can't use the URL
class for this scenario and need to duplicate some of its work.

* Only encode link URLs as a backup

If a URL can be created from a status href, don't try URL encoding
it as this could result in double encoding. Only encode the string
if the creation of a URL fails. This is also more efficient.
2023-08-23 07:08:12 +02:00
..
Sources/Models Support status links with non-ASCII characters (Bugfix 1546) (#1550) 2023-08-23 07:08:12 +02:00
Tests/ModelsTests Support status links with non-ASCII characters (Bugfix 1546) (#1550) 2023-08-23 07:08:12 +02:00
.gitignore Split Models from Network package 2022-11-29 09:28:17 +01:00
Package.swift Remove Atomics 2023-02-27 06:40:30 +01:00
README.md Split Models from Network package 2022-11-29 09:28:17 +01:00

Models

A description of this package.