kintesh / containerise

Firefox extension to automatically open websites in a container
MIT License
411 stars 55 forks source link

Rules do not work with URLs containing uppercase characters #120

Open archetyped opened 4 years ago

archetyped commented 4 years ago

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

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

Sazpaimon commented 4 years ago

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

archetyped commented 4 years ago

Thanks for the hack @Sazpaimon.

klint commented 3 years ago

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

ipwnponies commented 3 months ago

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