Merge lp:~dbarth/webbrowser-app/short-url-patterns into lp:webbrowser-app

Proposed by David Barth
Status: Merged
Approved by: David Barth
Approved revision: 677
Merged at revision: 709
Proposed branch: lp:~dbarth/webbrowser-app/short-url-patterns
Merge into: lp:webbrowser-app
Diff against target: 49 lines (+22/-1)
2 files modified
src/app/webcontainer/url-pattern-utils.cpp (+14/-1)
tests/unittests/container-url-patterns/tst_ContainerUrlPatternsTests.cpp (+8/-0)
To merge this branch: bzr merge lp:~dbarth/webbrowser-app/short-url-patterns
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Alexandre Abreu (community) Approve
Ubuntu Phablet Team Pending
Review via email: mp+231233@code.launchpad.net

Commit message

This branch adds support for url patterns without subdomains, ie of the form: https?://mydomain.com/*

Description of the change

This branch adds support for url patterns without subdomains, ie of the form: https?://mydomain.com/*

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:676
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/1044/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/3727
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2872/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-amd64-ci/243
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/243
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/243/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-i386-ci/243
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/3603
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4974
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4974/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/11692
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/2332/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3156
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3156/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/webbrowser-app-ci/1044/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

I wonder if there was a good reason for not considering short URLs in pattern filtering in the first place, or if it was simply overlooked. Alex, could you comment?

Revision history for this message
Olivier Tilloy (osomon) wrote :

The change looks good to me.

It looks like the block under "else if (isValidShortUrlPattern(pattern))" is exactly the same as the one under "if (isValidWebappUrlPattern(pattern))", maybe this could be factored out? I.e., either:

    if (isValidWebappUrlPattern(pattern) || isValidShortUrlPattern(pattern)) {
        …
    }

or factor out the contents of the block into a "transformValidWebappUrlPattern(…)" function.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I verified that the change fixes bug #1358399 indeed with the untappd app.

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

I tried to look up the discussions the we initially had w/ Jamie about it, but I cannot recall why it was left on the side (although it was done on purpose at the time). I cannot come up with a reasonable objection to this at this point,

See a few comments below, minor points though,

review: Approve
677. By David Barth

factor code and add test for strict domain matching

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:677
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/1073/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/4533/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/3365/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-amd64-ci/272
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/272
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/272/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-i386-ci/272
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/4314/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5785
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5785/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/12771
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/2770/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3667
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3667/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/webbrowser-app-ci/1073/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:677
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/1074/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/4543
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/3374/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-amd64-ci/273
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/273
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/273/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-i386-ci/273
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/4335
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5795
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5795/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/12795
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/2777/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3676
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3676/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/webbrowser-app-ci/1074/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webcontainer/url-pattern-utils.cpp'
2--- src/app/webcontainer/url-pattern-utils.cpp 2014-04-01 18:45:08 +0000
3+++ src/app/webcontainer/url-pattern-utils.cpp 2014-09-05 20:15:11 +0000
4@@ -77,12 +77,25 @@
5 return grammar.match(pattern).hasMatch();
6 }
7
8+/* A strict URL pattern has a strict domain name with no wildcard pattern,
9+ * and possibly regular path and protocol globs.
10+ *
11+ * @param pattern pattern that is to be tested for validity
12+ * @return true if the url is valid, false otherwise
13+ */
14+static bool isValidStrictUrlPattern(const QString& pattern)
15+{
16+ static QRegularExpression grammar("^http(s|s\\?)?://[^\\.\\*\\?]+\\.[^\\.\\*\\?]+(\\.[^\\.\\*\\?/]+)*/.*$");
17+ return grammar.match(pattern).hasMatch();
18+}
19+
20
21 QString UrlPatternUtils::transformWebappSearchPatternToSafePattern(const QString& pattern)
22 {
23 QString transformedPattern;
24
25- if (isValidWebappUrlPattern(pattern)) {
26+ if (isValidWebappUrlPattern(pattern) ||
27+ isValidStrictUrlPattern(pattern)) {
28
29 QRegularExpression urlRe("(.+://)([^/]+)(.+)");
30 QRegularExpressionMatch match = urlRe.match(pattern);
31
32=== modified file 'tests/unittests/container-url-patterns/tst_ContainerUrlPatternsTests.cpp'
33--- tests/unittests/container-url-patterns/tst_ContainerUrlPatternsTests.cpp 2014-04-30 12:03:55 +0000
34+++ tests/unittests/container-url-patterns/tst_ContainerUrlPatternsTests.cpp 2014-09-05 20:15:11 +0000
35@@ -40,6 +40,14 @@
36 << "https?://*.mydomain.com/*"
37 << "https?://[^\\./]*.mydomain.com/[^\\s]*";
38
39+ QTest::newRow("Valid pattern - short url")
40+ << "https?://mydomain.com/*"
41+ << "https?://mydomain.com/[^\\s]*";
42+
43+ QTest::newRow("Valid pattern - strict url")
44+ << "https?://www.mydomain.com/*"
45+ << "https?://www.mydomain.com/[^\\s]*";
46+
47 #define WEBAPP_INVALID_URL_PATTERN_TEST(id,invalid_url_pattern) \
48 QTest::newRow("Invalid pattern " #id) \
49 << invalid_url_pattern \

Subscribers

People subscribed via source and target branches

to status/vote changes: