Merge lp:~vasilev/psiphon/sprint3-610176 into lp:psiphon

Proposed by Robert Vasilev
Status: Superseded
Proposed branch: lp:~vasilev/psiphon/sprint3-610176
Merge into: lp:psiphon
Diff against target: 194 lines (+61/-10)
6 files modified
trunk/mod_psiphon/mod_psiphon_headers/mod_psiphon_headers.c (+8/-2)
trunk/sql/upgrade-2.6.sql (+4/-0)
trunk/tools/psiphon_install.sh (+1/-1)
trunk/www/bluebar.php (+6/-1)
trunk/www/custom_user_agent.php (+15/-6)
trunk/www/includes/lang.php (+27/-0)
To merge this branch: bzr merge lp:~vasilev/psiphon/sprint3-610176
Reviewer Review Type Date Requested Status
Adam Kruger Disapprove
Review via email: mp+33767@code.launchpad.net

This proposal has been superseded by a proposal from 2010-09-01.

Commit message

Fixes for https://bugs.launchpad.net/psiphon/+bug/610176

Implemented functionality described in Adam's comment.

1. Added 'back_link' field in 'useragent' table.
2. Patched mod_psiphon_headers.c to retrieve corresponding 'back_link' value from database and store in apache table.
3. Patched bluebar.php to display appropriate compatibility mode exit link.
4. Patched custom_user_agent.php admin page to add 'back_link' manipulating functionality.

Description of the change

Fixes for https://bugs.launchpad.net/psiphon/+bug/610176

1. Patched mod_psifon_headers.c to store custom user agent value in apache table.
2. Patched bluebar.php to display custom user agent value, if such is set up.
3. Added useragent_helpers.php to get simplified browser name from full user agent string.
4. Added stub for future phpunit tests for useragent_helpers.php.

Traslations for lang.php/browse_as value are needed.

To post a comment you must log in.
Revision history for this message
Adam Kruger (adam-kruger) wrote :

The bug description was not clear and so what is implemented is not what was intended.
We would like a link to appear on the bluebar when a custom user agent is being sent (this part was implemented as intended).
The text of the link should be the following: "Exit Compatibility Mode"
The link's href should be a value that is stored in a new column of the user agent table, corresponding to the custom user agent record that is in use.

Please ask if you need any further clarification.

review: Disapprove
Revision history for this message
Robert Vasilev (vasilev) wrote :

> The link's href should be a value that is stored in a new column of the user
> agent table, corresponding to the custom user agent record that is in use.

Adam, thank you for comments.

Please clarify what data need to be stored in the new column of user agent table.

We guess that it is "Simplified user agent name", and intended link's href looks like
"/exitCompatibilityMode.php?userAgent=Firefox", where "Firefox" string is stored in the mentioned new field of the DB table.

Revision history for this message
Robert Vasilev (vasilev) wrote :

Another question:

How to implement "Exit Compatibility Mode" feature ?
Where are several choices:
1. Per-page.
2. Per-session (psiphon-session).
3. Globally.

If not-per-psiphon-session mode, where do we need to store user per-domain preferences ? In DB ? In cookies ?

Revision history for this message
Adam Kruger (adam-kruger) wrote :

Robert, the data stored in the new column of the user agent table will be the link's full href.

We considered the following example to drive the design of this feature:

Some of Facebook's basic features work through Psiphon. Some, like Messages, do not. So when the user clicks on Messages in Facebook, we want to send a mobile user agent along with the request. This actually results in Facebook redirecting to m.facebook.com, and the user is now able to send messages through the m.facebook interface.

The problem at this point is that the user is now at the m.facebook.com site, and we don't want to force the user to hunt for the "Desktop version" or "Full version" link to resume their usual experience with the rest of the site. Our solution here is to provide a link on the bluebar with href="www.facebook.com". This will bring the user back to the usual facebook home screen in desktop mode.

By configuring the full href link in the custom user agent table, we are able to make a decision on a per site basis about how to bring the user back to the desktop version. We accept that this strategy may not be suitable for all websites (ie where the website uses a cookie to decide which content to send).

So the purpose of this feature is 1. to provide the user with some visual feedback indicating that they are browsing in a special compatibility mode, and 2. to provide the user with a link back to the Desktop version of the website, so they don't have to hunt for that link themselves.

To answer your second question, we do not want to store any user per-domain preferences at this time. The "Exit Compatibility Mode" feature should not override any existing Psiphon behavior. It is simply a link that we will configure for each custom user agent entry.

Revision history for this message
Robert Vasilev (vasilev) wrote :

Adam, thank you for the answers and descriptive example.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'trunk/mod_psiphon/mod_psiphon_headers/mod_psiphon_headers.c'
2--- trunk/mod_psiphon/mod_psiphon_headers/mod_psiphon_headers.c 2010-06-22 17:11:34 +0000
3+++ trunk/mod_psiphon/mod_psiphon_headers/mod_psiphon_headers.c 2010-09-01 14:48:14 +0000
4@@ -740,6 +740,7 @@
5 const char* domain_db = 0;
6 const char* path = 0;
7 const char* path_db = 0;
8+ const char* back_link = 0;
9 char* query = 0;
10 apr_dbd_results_t* res = 0;
11 apr_dbd_row_t* row = 0;
12@@ -766,7 +767,7 @@
13 return 0;
14 }
15
16- query = apr_pstrdup(p, "SELECT domain, path, user_agent_string FROM useragent ORDER BY id DESC");
17+ query = apr_pstrdup(p, "SELECT domain, path, user_agent_string, back_link FROM useragent ORDER BY id DESC");
18
19 if (error = apr_dbd_select(dbd->driver,p,dbd->handle, &res, query, 0))
20 {
21@@ -802,9 +803,13 @@
22 {
23 match_length_so_far = match_length;
24 user_agent_string = apr_pstrdup(p, apr_dbd_get_entry(dbd->driver, row, 2));
25+ back_link = apr_pstrdup(p, apr_dbd_get_entry(dbd->driver, row, 3));
26 }
27 }
28-
29+ if (back_link && *back_link)
30+ {
31+ apr_table_set(r->subprocess_env, "psiphon_custom_user_agent_back_link", back_link);
32+ }
33 return user_agent_string;
34 }
35
36@@ -861,6 +866,7 @@
37 {
38 /* If we found a non 0 length user agent string, then set the custom user agent */
39 apr_table_set(r->headers_in, "User-Agent", user_agent_string);
40+ apr_table_set(r->subprocess_env, "psiphon_custom_user_agent", user_agent_string);
41 }
42
43 /* Add cookies headers from DB for authenticated user*/
44
45=== added file 'trunk/sql/upgrade-2.6.sql'
46--- trunk/sql/upgrade-2.6.sql 1970-01-01 00:00:00 +0000
47+++ trunk/sql/upgrade-2.6.sql 2010-09-01 14:48:14 +0000
48@@ -0,0 +1,4 @@
49+--
50+-- Modifications to table useragent for handling compatibility mode exit link
51+--
52+ALTER TABLE useragent ADD back_link text;
53
54=== modified file 'trunk/tools/psiphon_install.sh'
55--- trunk/tools/psiphon_install.sh 2010-06-01 17:50:42 +0000
56+++ trunk/tools/psiphon_install.sh 2010-09-01 14:48:14 +0000
57@@ -271,7 +271,7 @@
58 echo "Enter current password for mysql root (enter for none)"
59
60 cat sql/create_db.sql sql/grant.new.sql sql/structure.2.3.sql sql/init.sql \
61-sql/upgrade-2.4.sql sql/upgrade-2.5.sql sql/jsf.sql sql/youtube.sql | mysql -uroot -p
62+sql/upgrade-2.4.sql sql/upgrade-2.5.sql sql/upgrade-2.6.sql sql/jsf.sql sql/youtube.sql | mysql -uroot -p
63
64 rm sql/grant.new.sql
65
66
67=== modified file 'trunk/www/bluebar.php'
68--- trunk/www/bluebar.php 2010-07-14 20:51:28 +0000
69+++ trunk/www/bluebar.php 2010-09-01 14:48:14 +0000
70@@ -65,7 +65,6 @@
71 !strncmp($uri, "https://", 8))) {
72 $uri="";
73 }
74-
75 ?>
76
77 <!--bluebar-->
78@@ -82,6 +81,12 @@
79 <?
80 echo $v;
81
82+// Indicate custom user agent, if it configured for the proxied URL
83+
84+if (isset($_SERVER["psiphon_custom_user_agent"]) && isset($_SERVER["psiphon_custom_user_agent_back_link"])) {
85+ echo "<a href=\"".$prefix."/".$_SERVER["psiphon_custom_user_agent_back_link"]."\" target=\"_top\">".utf8_encode_string(msg("exit_compatibility_mode"))."</a> |\n";
86+}
87+
88 // Add link create for Anonymous Users
89
90 if (is_anonymous_user($record_user))
91
92=== modified file 'trunk/www/custom_user_agent.php'
93--- trunk/www/custom_user_agent.php 2010-06-28 20:26:25 +0000
94+++ trunk/www/custom_user_agent.php 2010-09-01 14:48:14 +0000
95@@ -39,8 +39,8 @@
96 if ($_POST['id']=="add")
97 {
98 $query =
99- "INSERT INTO useragent (domain, path, user_agent_string) ".
100- "VALUES (:domain, :path, :user_agent_string)";
101+ "INSERT INTO useragent (domain, path, user_agent_string, back_link) ".
102+ "VALUES (:domain, :path, :user_agent_string, :back_link)";
103
104 db_query_execute(
105 $config,
106@@ -48,7 +48,9 @@
107 convert_null_array(array(
108 ":domain" => $_POST['domain'],
109 ":path" => $_POST['path'],
110- ":user_agent_string" => $_POST['user_agent_string'])));
111+ ":user_agent_string" => $_POST['user_agent_string'],
112+ ":back_link" => $_POST['back_link']
113+ )));
114
115 $last = db_get_last_insert_id($config);
116 }
117@@ -62,7 +64,8 @@
118 "UPDATE useragent SET ".
119 "domain = :domain, ".
120 "path = :path, ".
121- "user_agent_string = :user_agent_string ".
122+ "user_agent_string = :user_agent_string, ".
123+ "back_link = :back_link ".
124 "WHERE id = :id";
125
126 db_query_execute(
127@@ -72,6 +75,7 @@
128 ":domain" => $_POST['domain'],
129 ":path" => $_POST['path'],
130 ":user_agent_string" => $_POST['user_agent_string'],
131+ ":back_link" => $_POST['back_link'],
132 ":id" => $_POST['id'])));
133
134 $last = $_POST['id'];
135@@ -123,6 +127,11 @@
136 <?=msg("user_agent_string")?>
137 <br>
138 <textarea name="user_agent_string" cols="60" rows="5"><?=escape_html($_POST['user_agent_string'])?></textarea>
139+
140+ <br>
141+ <?=msg("back_link")?>
142+ <br>
143+ <textarea name="back_link" cols="60" rows="2"><?=escape_html($_POST['back_link'])?></textarea>
144 </td>
145
146 <td>
147@@ -159,8 +168,8 @@
148 echo "<td colspan=\"3\">\n<input type=\"hidden\" name=\"id\" value=\"{$record['id']}\" />\n";
149 echo msg("domain")."\n<br>\n<input type=\"text\" name=\"domain\" maxlength=\"64\" size=\"20\" value=\"".$record['domain']."\" />\n<br>\n";
150 echo msg("path")."\n<br>\n<input type=\"text\" name=\"path\" maxlength=\"255\" size=\"60\" value=\"".$record['path']."\" />\n<br>\n";
151-
152- echo msg("user_agent_string")."\n<br>\n<textarea name=\"user_agent_string\" cols=\"60\" rows=\"5\">\n".$record['user_agent_string']."</textarea>\n</td>\n";
153+ echo msg("user_agent_string")."\n<br>\n<textarea name=\"user_agent_string\" cols=\"60\" rows=\"5\">\n".$record['user_agent_string']."</textarea>\n<br>\n";
154+ echo msg("back_link")."\n<br>\n<textarea name=\"back_link\" cols=\"60\" rows=\"2\">\n".$record['back_link']."</textarea>\n</td>\n";
155
156 echo "<td>{$_p}<input type=\"submit\" value=\"".msg("save")."\" /> &nbsp; <a href=\"".getenv("SCRIPT_NAME")."?fresh={$fresh}\">".msg("cancel")."</a>{$_s}</td>\n";
157 }
158
159=== modified file 'trunk/www/includes/lang.php'
160--- trunk/www/includes/lang.php 2010-08-09 18:56:53 +0000
161+++ trunk/www/includes/lang.php 2010-09-01 14:48:14 +0000
162@@ -4630,6 +4630,33 @@
163 Please begin using this URL to log into Psiphon.",
164 ),
165
166+ 'exit_compatibility_mode' => array(
167+ 'en' => "Exit Compatibility Mode",
168+ 'fa' => "Exit Compatibility Mode",
169+ 'ru' => "Exit Compatibility Mode",
170+ 'uz' => "Exit Compatibility Mode",
171+ 'tk' => "Exit Compatibility Mode",
172+ 'cn' => "Exit Compatibility Mode",
173+ 'ar' => "Exit Compatibility Mode",
174+ 'vt' => "Exit Compatibility Mode",
175+ 'fr' => "Exit Compatibility Mode",
176+ 'es' => "Exit Compatibility Mode",
177+ ),
178+
179+ 'back_link' => array(
180+ 'en' => "Exit Compatibility Mode link",
181+ 'fa' => "Exit Compatibility Mode link",
182+ 'ru' => "Exit Compatibility Mode link",
183+ 'uz' => "Exit Compatibility Mode link",
184+ 'tk' => "Exit Compatibility Mode link",
185+ 'cn' => "Exit Compatibility Mode link",
186+ 'ar' => "Exit Compatibility Mode link",
187+ 'vt' => "Exit Compatibility Mode link",
188+ 'fr' => "Exit Compatibility Mode link",
189+ 'es' => "Exit Compatibility Mode link",
190+ ),
191+
192+
193 // DO NOT MODIFY THIS LINE -- END OF TRANSLATIONS
194 );
195

Subscribers

People subscribed via source and target branches