processwire / processwire-issues

ProcessWire issue reports.
45 stars 2 forks source link

Url field: When modifying a valid url, entering invalid characters will delete both the invalid and the original / valid url #1705

Closed klor closed 1 year ago

klor commented 1 year ago

Short description of the issue

When using a url field on a page in the ProcessWire editing interface: When modifying a valid url, entering a url with invalid characters will delete both the invalid and the original / valid url

Expected behavior

Actual behavior

This url is saved in my page: image

As an editor, I modify the url (note the invalid Danish ø-character -> https://prøcesswire.com/) image

Error message is shown - url is gone image

On page refresh, the url is still gone image

Optional: Suggestion for a possible fix

Steps to reproduce the issue

  1. Create template 'foo'
  2. Add url field
  3. Create page (use template 'foo')
  4. Enter valid url: https://processwire.com/
  5. Save page. Url field is now populated
  6. Modify url: https://prøcesswire.com/
  7. Save page
  8. Refresh page (press CTRL+F5 on Windows). Url field is now empty.

Setup/Environment

matjazpotocnik commented 1 year ago

Ryan, it looks like if($error) $value = $this->val(); is missing at the and of setAttributeValue() in InputfieldURL.php ?

Klor, just for info, URL field allows IDN characters.

ryancramerdesign commented 1 year ago

Thanks @klor and @matjazpotocnik I've added matjazpotocnik suggested fix for this.

matjazpotocnik commented 1 year ago

@klor closing this, let me know if the fix isn't working for you.