Merge lp:~rpadovani/webbrowser-app/data-address into lp:webbrowser-app

Proposed by Riccardo Padovani
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 974
Merged at revision: 1003
Proposed branch: lp:~rpadovani/webbrowser-app/data-address
Merge into: lp:webbrowser-app
Prerequisite: lp:~osomon/webbrowser-app/about-blank
Diff against target: 77 lines (+15/-3)
3 files modified
src/app/webbrowser/AddressBar.qml (+1/-1)
src/app/webbrowser/urlManagement.js (+6/-1)
tests/unittests/qml/tst_AddressBar.qml (+8/-1)
To merge this branch: bzr merge lp:~rpadovani/webbrowser-app/data-address
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+256367@code.launchpad.net

Commit message

Add support for data: URIs in the address bar, and remove length limitation for TLDs.

Description of the change

Fix bug #1377953 - data: URIs don't work

You can find some tests here: http://www-archive.mozilla.org/quality/networking/testing/datatests.html

They don't work all as expected (as described in the page), but they work as Chromium on vivid, so I think it's acceptable

Fix bug #1441281 - update looksLikeAUrl().

Remove .tdl regex length limitation (min 2, max *)

Based on lp:~osomon/webbrowser-app/about-blank

To post a comment you must log in.
969. By Riccardo Padovani

Update tests

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

8 + } else if (address.substr(0, 4).toLowerCase == "data:") {
9 + return address.substr(0, 4).toLowerCase + address.substr(5);

I’d suggest using a regexp instead of String.substr(…), and no need to do the substr() dance again if you know that the scheme in lowercase is "data":

    if (address.match(/^data:/i)) {
        return "data:" + address.substr(5)
    }

Note that the CI job failed because your changes break the existing unit tests, probably because the call to substr should have been with a length of 5, not 4.

review: Needs Fixing
970. By Riccardo Padovani

Use regex instead of substr

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Thanks for the feedback, you're totally right :-)

Fixed!

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

I’m still seeing unit test failures. To run the unit tests locally and fix them:

    ctest -V -R tst_QmlTests

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
971. By Riccardo Padovani

Fix data uri tests

972. By Riccardo Padovani

Merge from upstream

973. By Riccardo Padovani

Fix implementation of urlManagement for data: address

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Tests fail because my implementation was wrong :-)

So, the data: address could has space in the url, so I need to check if is a data: address before checking if there are space in the address.

Then, for tdl, I need to check if the tld is > 2 ({2,}) and not 2 ({2}). Now should be all ok!

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

There’s no new unit test for longer TLDs.
The changes otherwise look good.

review: Needs Fixing
974. By Riccardo Padovani

Add test for tld longer than 3 chars

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Right.

I used http://com.google because it's the only valid one I know, is it ok?

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

That looks good now, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webbrowser/AddressBar.qml'
2--- src/app/webbrowser/AddressBar.qml 2015-04-14 21:13:19 +0000
3+++ src/app/webbrowser/AddressBar.qml 2015-04-28 07:20:23 +0000
4@@ -257,7 +257,7 @@
5
6 function simplifyUrl(url) {
7 var urlString = url.toString()
8- if (urlString == "about:blank") {
9+ if (urlString == "about:blank" || urlString.match(/^data:/i)) {
10 return url
11 }
12 var hasProtocol = urlString.indexOf("://") != -1
13
14=== modified file 'src/app/webbrowser/urlManagement.js'
15--- src/app/webbrowser/urlManagement.js 2015-04-14 21:13:19 +0000
16+++ src/app/webbrowser/urlManagement.js 2015-04-28 07:20:23 +0000
17@@ -21,6 +21,8 @@
18 var url = address
19 if (address.toLowerCase() == "about:blank") {
20 return address.toLowerCase()
21+ } else if (address.match(/^data:/i)) {
22+ return "data:" + address.substr(5)
23 } else if (address.substr(0, 1) == "/") {
24 url = "file://" + address
25 } else if (address.indexOf("://") == -1) {
26@@ -30,6 +32,9 @@
27 }
28
29 function looksLikeAUrl(address) {
30+ if (address.match(/^data:/i)) {
31+ return true;
32+ }
33 var terms = address.split(/\s/)
34 if (terms.length > 1) {
35 return false
36@@ -45,7 +50,7 @@
37 address.match(/^[a-z]+:\/\//i)) {
38 return true
39 }
40- if (address.split('/', 1)[0].match(/\.[a-zA-Z]{2,4}$/)) {
41+ if (address.split('/', 1)[0].match(/\.[a-zA-Z]{2,}$/)) {
42 return true
43 }
44 if (address.split('/', 1)[0].match(/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}/)) {
45
46=== modified file 'tests/unittests/qml/tst_AddressBar.qml'
47--- tests/unittests/qml/tst_AddressBar.qml 2015-04-14 21:13:19 +0000
48+++ tests/unittests/qml/tst_AddressBar.qml 2015-04-28 07:20:23 +0000
49@@ -91,6 +91,8 @@
50 {url: "https://google.com"},
51 {url: "ftp://ubuntu.com"},
52 {url: "about:blank"},
53+ {url: "data:,A brief note"},
54+ {url: "http://com.google"}
55 ]
56 }
57
58@@ -194,6 +196,8 @@
59 {text: "FILE:///usr/share/doc/ubuntu-online-tour/index.html", requestedUrl: "file:///usr/share/doc/ubuntu-online-tour/index.html"},
60 {text: "FTP://ubuntu.com", requestedUrl: "ftp://ubuntu.com"},
61 {text: "ABOUT:BLANK", requestedUrl: "about:blank"},
62+ {text: "DATA:,A brief note", requestedUrl: "data:,A brief note"},
63+ {text: "HTTP://com.GOOGLE", requestedUrl: "http://com.google"}
64 ]
65 }
66
67@@ -242,7 +246,10 @@
68 actualUrl: "http://en.wikipedia.org"},
69 {input: "en.wikipedia.org/wiki/Foo",
70 simplified: "en.wikipedia.org",
71- actualUrl: "http://en.wikipedia.org/wiki/Foo"}
72+ actualUrl: "http://en.wikipedia.org/wiki/Foo"},
73+ {input: "http://com.google",
74+ simplified: "com.google",
75+ actualUrl: "http://com.google"},
76 ]
77 }
78

Subscribers

People subscribed via source and target branches

to status/vote changes: