processwire / processwire-requests

ProcessWire feature requests.
39 stars 0 forks source link

Create a FieldtypeURI to complement FieldtypeURL #529

Open solonmedia opened 3 months ago

solonmedia commented 3 months ago

Short description of the enhancement

It would be great to add a URI fieldtype to core to allow for easier manipulation of protocols outside those typically parsed by parse_url.

There is a library that extends and enhances parse_url into a parse_uri method that seems to be a drop-in replacement for parse_url but would extend the options to include a facility to parse additional protocols.

https://github.com/peterpostmann/php-parse_uri

Current vs. suggested behavior

Right now if you are using a protocol link URI that parse_url does not understand, an error will be thrown using the FieldtypeURL.

An example of this would be the sms: protocol which works similar to the tel: protocol but pushes a request to open a messaging app rather than the phone app. This currently fails with FieldtypeURL

Extending this to include URI or have an optional URI Fieldtype with additional security features would be useful.

ryancramerdesign commented 2 months ago

@solonmedia Sounds like a good idea, though I'm not sure the need is common enough to require a full Fieldtype/Inputfield just for this purpose. What about using the "text" field with the "pattern" setting? If server-side validation was also needed in the application, a hook after the Inputfield's processInput() method could use that library you mentioned. All of this could be bundled into a non-core URI Fieldtype/Inputfield module for when the need comes up, or maybe just the Inputfield.