The default bug view has changed. See this FAQ.

MatchPattern incorrectly matches patterns with wildcard

RESOLVED FIXED in mozilla23

Status

Add-on SDK
General
P2
normal
RESOLVED FIXED
4 years ago
a year ago

People

(Reporter: fxrock2002, Assigned: jsantell)

Tracking

unspecified
mozilla23

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

4 years ago
User Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.70 Safari/537.17

Steps to reproduce:

According to the match-pattern documentation:  

"A domain name prefixed with an asterisk and dot matches any URL of that domain or a subdomain, using any of http, https, ftp."

However, I have a MatchPattern setup to match "*.ign.com" and ANYTHING that ends in ign.com is matched. For example: design.com is matched, and even activesouldesign.com is matched. These are not subdomains of ign.com. A regular expression would be a workaround, but this defeats the purpose of having wildcards as an alternative for developer ease-of-use.

https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/page-mod/match-pattern.html


Actual results:

console.log(new MatchPattern('*.ign.com').test('http://ign.com'));   // true
console.log(new MatchPattern('*.ign.com').test('http://www.ign.com')); // true
console.log(new MatchPattern('*.ign.com').test('http://www.design.com')); // true
console.log(new MatchPattern('*.ign.com').test('http://activesouldesign.com')); // true



Expected results:

console.log(new MatchPattern('*.ign.com').test('http://ign.com'));   // true
console.log(new MatchPattern('*.ign.com').test('http://www.ign.com'));  // true
console.log(new MatchPattern('*.ign.com').test('http://www.design.com'));  // false
console.log(new MatchPattern('*.ign.com').test('http://activesouldesign.com')); // false
(Assignee)

Updated

4 years ago
Assignee: nobody → jsantell

Updated

4 years ago
Priority: -- → P2
Thanks fxrock, the following tests will now correctly fail once patched

ok('*.ign.com', 'http://www.design.com');
ok('*.ign.com', 'http://design.com');
ok('*.zilla.com', 'http://bugzilla.mozilla.com');
ok('*.zilla.com', 'http://mo-zilla.com');
Created attachment 733496 [details] [diff] [review]
GH Pull Request 923
Created attachment 733497 [details]
GH Pull Request 923
Attachment #733497 - Flags: review?(zer0)
Comment on attachment 733497 [details]
GH Pull Request 923

Good catch! But I see some issues in your implementation. Take a look to the comments I wrote on Github.
Attachment #733497 - Flags: review?(zer0) → review-
Created attachment 733715 [details]
GH Pull Request 923
Attachment #733715 - Flags: review?(zer0)
Attachment #733715 - Flags: review?(zer0) → review+

Comment 6

4 years ago
Commit pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/f36c6dac5ad2ac4c3757b17b157f162614cc8591
Merge pull request #923 from jsantell/fix-matchpattern-856913

Fix Bug 856913, fix match pattern wildcard to not match invalid domains, r=@ZER0

Updated

4 years ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
(Reporter)

Comment 7

4 years ago
Still experiencing this bug with the latest add-on sdk 1.14 and firefox 22. How can I see what version the fix will be included in?
I believe this landed for Firefox 23, and the version of this file in the the Firefox23 branch of the SDK looks like it contains this patch: https://github.com/mozilla/addon-sdk/blob/firefox23/lib/sdk/page-mod/match-pattern.js

Updated

4 years ago
Target Milestone: --- → mozilla23

Comment 9

a year ago
dies ist Geburtstagswünsche Blog. hier finden Sie am besten Zitate, sms für Wunsch, den Ihr Freund, ein Familienmitglied und alle Ihre liebevolle Person erhalten


<a href="http://www.geburtstagswuensche4u.com/">Geburtstagswünsche</a>
You need to log in before you can comment on or make changes to this bug.