singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.6k stars 840 forks source link

Prevent inserting illegal characters into a link #2326

Open mbenci opened 1 month ago

mbenci commented 1 month ago

Is there an existing issue for this?

Flutter Quill version

10.8.4

Steps to reproduce

Focus the quill editor Type https://google.com/ Type , or )

Expected results

The char "," or ") "should not be part of the link.

Actual results

The char "," or ") " is part of the link and the link does not work

Additional Context

No response

orevial commented 1 month ago

, and ) (and *, (, !...) are all valid characters as soon as they don't appear in the host part.

To me quill editor works as expected when it comes to the handling of these characters:

Take this Google Maps position URL as an example :

https://www.google.fr/maps/place/Paris/@48.8588475,2.3058358,13z/data=!3m1!4b1!4m6!3m5!1s0x47e66e1f06e2b70f:0x40b82c3688c9460!8m2!3d48.8575475!4d2.3513765!16zL20vMDVxdGo?entry=ttu&g_ep=EgoyMDI0MTAyMi4wIKXMDSoASAFQAw%3D%3D

As you can see, they are using @, ! or even , as part of the path, and IMO we should definitely be able to support that in Quill Editor

mbenci commented 3 weeks ago

Thanks for the reply and the choice is understandable. However, there remains a problem which in my opinion is a bug: if I write https://www.google.it, the ',' is part of the link (correct), but if I delete the ',' it continues to be part of the link (wrong), same thing with other characters like '.' ')' etc

Also I think this regex covers more cases r'((http|https)://)|(www.)+[a-z0-9]+([\-\.]{1}[a-z0-9]+)([-A-Z0-9.]+)(/[-A-Z0-9+&@#/%=~_|!:,.;]*)?(\?[A-Z0-9+&@#/%=~_|!:‌​,.;]*)?' What do you think?

CatHood0 commented 3 weeks ago

I'm working on a way to prevent events using the QuillController and a new parameter for QuillEditorConfigurations.