[Users] Support for URL encoding

Pierre Fortin pf at pfortin.com
Sat Jul 23 18:14:48 UTC 2022


On Sat, 23 Jul 2022 17:36:37 -0000 Paul wrote:

>On Sat, 23 Jul 2022 12:44:08 -0000
>Paul <paul at claws-mail.org> wrote: 
>
>> Isn't it python's urllib.parse.quote() which is broken?  
>
>To answer my own question: no. When you want to output the url, use
>urllib.parse.unquote().

.quote()  encodes (CM doesn't treat as a link)
.unquote()  decodes (CM thinks the link ends at the first space)

What I need is .quote() to be able to encode a URL which contains spaces.
When I use .quote(), CM fails to treat it as a link, or fails to decode it
in order to treat it as a link...

This encodes the URL:
>>> urllib.parse.quote("https://s3.amazonaws.com/dl.ncsbe.gov/State_Board_Meeting_Docs/Orders/Declaratory Rulings/NCSBE Declaratory Ruling 072222 re Absentee Signature Matching.pdf")
'https%3A//s3.amazonaws.com/dl.ncsbe.gov/State_Board_Meeting_Docs/Orders/Declaratory%20Rulings/NCSBE%20Declaratory%20Ruling%20072222%20re%20Absentee%20Signature%20Matching.pdf'

This doesn't even change the URL:
>>> urllib.parse.unquote("https://s3.amazonaws.com/dl.ncsbe.gov/State_Board_Meeting_Docs/Orders/Declaratory Rulings/NCSBE Declaratory Ruling 072222 re Absentee Signature Matching.pdf")
'https://s3.amazonaws.com/dl.ncsbe.gov/State_Board_Meeting_Docs/Orders/Declaratory
Rulings/NCSBE Declaratory Ruling 072222 re Absentee Signature
Matching.pdf'

If I don't use urllib.parse.* at all, the sent URL is:
https://s3.amazonaws.com/dl.ncsbe.gov/State_Board_Meeting_Docs/Orders/Declaratory Rulings/NCSBE Declaratory Ruling 072222 re Absentee Signature Matching.pdf

where CM quits treating the string as a link at the first space,
destroying its usefulness...

Looks like my option is to use:

 urllib.parse.quote( s ).replace("%3A",":") 

which gets rid of the spaces to get around CM truncating the link, and
restore ':' to overcome .quote()'s aggressive behavior...  Done.

HTH
Cheers!

>with regards
>
>Paul
>_______________________________________________
>Users mailing list
>Users at lists.claws-mail.org
>https://lists.claws-mail.org/cgi-bin/mailman/listinfo/users
>


More information about the Users mailing list