narrowly tailor repo URL matching to avoid false matches

With so many patterns being matched, it is highly likely that there will be
false positives, i.e. random URLs will trigger the prompt of whether to use
F-Droid or not.  The updated set of patterns narrowly tailors the matches
so that it is highly unlikely to match URLs that are not fdroid repos, yet
still makes it useful both as a generic repo and a peer-to-peer
bootstrapping repo.

This set of patterns only matches URLs like this:

https://foo.org/fdroid/repo
https://foo.org/fdroid/repo/
https://foo.org/fdroid/repo/////

It does not match URLs like this:

https://f-droid.org/repo
https://myblog.com/thoughts-about-my-lovely-fdroid-repo
https://news.com/tag/repo
https://somesite.com/repo/this-is-my-stuff

It matches multiple slashes to since those are in effect the same URL, and
they sometimes show up as typos.  This does not include mvdan's proposal
for the 'fdroid-bootstrap' tag on the end because its not something that I
would use in this current project, so I don't know how best to apply it.  I
have no objection to the 'fdroid-bootstrap' proposal.
This commit is contained in:
Hans-Christoph Steiner 2013-12-02 15:37:49 -05:00
parent 7dfe9eac24
commit a3ac298ae4

View File

@ -78,24 +78,28 @@
<data android:scheme="http" /> <data android:scheme="http" />
<data android:scheme="https" /> <data android:scheme="https" />
<data android:host="*" /> <data android:host="*" />
<!-- the patterns are unpredictable, this is the best I could get working --> <!--
<data android:path="/repo" /> The pattern matcher here is poorly implemented, in particular the * is
<data android:path="/archive" /> non-greedy, so you have to do stupid tricks to match patterns that have
<data android:pathPattern="/repo/*" /> repeat characters in them. http://stackoverflow.com/a/8599921/306864
<data android:pathPattern="/archive/*" /> -->
<data android:pathPattern="/.*/repo" /> <data android:path="/fdroid/repo" />
<data android:pathPattern="/.*/archive" /> <data android:pathPattern="/fdroid/repo/*" />
<data android:pathPattern="/.*/repo/*" /> <data android:pathPattern="/.*/fdroid/repo" />
<data android:pathPattern="/.*/archive/*" /> <data android:pathPattern="/.*/fdroid/repo/*" />
<data android:pathPattern="/.*/.*/repo" /> <data android:pathPattern="/.*/.*/fdroid/repo" />
<data android:pathPattern="/.*/.*/archive" /> <data android:pathPattern="/.*/.*/fdroid/repo/*" />
<data android:pathPattern="/.*/.*/repo/*" /> <data android:pathPattern="/.*/.*/.*/fdroid/repo" />
<data android:pathPattern="/.*/.*/archive/*" /> <data android:pathPattern="/.*/.*/.*/fdroid/repo/*" />
<data android:pathPattern="/.*/.*/.*/repo" /> <data android:path="/fdroid/archive" />
<data android:pathPattern="/.*/.*/.*/archive" /> <data android:pathPattern="/fdroid/archive/*" />
<data android:pathPattern="/.*/.*/.*/repo/*" /> <data android:pathPattern="/.*/fdroid/archive" />
<data android:pathPattern="/.*/.*/.*/archive/*" /> <data android:pathPattern="/.*/fdroid/archive/*" />
</intent-filter> <data android:pathPattern="/.*/.*/fdroid/archive" />
<data android:pathPattern="/.*/.*/fdroid/archive/*" />
<data android:pathPattern="/.*/.*/.*/fdroid/archive" />
<data android:pathPattern="/.*/.*/.*/fdroid/archive/*" />
</intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />