containerise icon indicating copy to clipboard operation
containerise copied to clipboard

Rules do not work with URLs containing uppercase characters

Open archetyped opened this issue 5 years ago • 4 comments

Rules do not match URLs containing uppercase characters.

This appears to be because all rules are converted to lowercase, and then are tested in a case-sensitive manner:

// From matchesSavedMap()
new RegExp(regex).test(toMatch);

Unfortunately, users don't have control over the URLs used in links, etc. so if a URL contains uppercase characters where a rule's pattern depends on, the rule will not match it.

Example

  • URL: https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&AppName=ImpactEP-EPN-PRD
    • Standard eBay login URL, but with different query string for different properties.
  • Rule:
    • Original: @https?:\/{2}signin\.ebay\.com\/.+AppName=ImpactEP-EPN.*
    • Converted by Containerise: @https?:\/{2}signin\.ebay\.com\/.+appname=impactep-epn.*
  • Result: The rule (after lowercase conversion by Containerise) does not match the URL.

Note: The rule's regex pattern has been confirmed to match when the URL was manually converted to lowercase.

archetyped avatar Feb 20 '20 02:02 archetyped

I also experienced this, and as a lazy workaround, I simply replaced the uppercase character with the ascii hex code. So your example regex would become: https?:\/{2}signin\.ebay\.com\/.+\x41pp\x4eame=\x49mpact\x45\x50-\x45\x50\x4e.* Far from ideal, though

Sazpaimon avatar Feb 27 '20 15:02 Sazpaimon

Thanks for the hack @Sazpaimon.

archetyped avatar Feb 29 '20 07:02 archetyped

Also experiencing this bug... :( Looking forward to a resolution (I'm too lazy to use ASCII code ;) )

klint avatar Apr 20 '21 08:04 klint

Here's a python oneliner to convert upper case letters to unicode hex escapes. Thanks @Sazpaimon for https://github.com/kintesh/containerise/issues/120#issuecomment-592029826

URL='https://FooBar.com/pathWithTitleCase'
python -c "print(''.join(fr'\x{i.encode().hex()}' if i.isupper() else i for i in '$URL'))"

# Produces https://\x46oo\x42ar.com/path\x57ith\x54itle\x43ase

ipwnponies avatar May 16 '24 19:05 ipwnponies