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
=== modified file 'trunk/mod_psiphon/mod_psiphon_headers/mod_psiphon_headers.c'
--- trunk/mod_psiphon/mod_psiphon_headers/mod_psiphon_headers.c 2010-06-22 17:11:34 +0000
+++ trunk/mod_psiphon/mod_psiphon_headers/mod_psiphon_headers.c 2010-09-01 14:48:14 +0000
@@ -740,6 +740,7 @@
740 const char* domain_db = 0;740 const char* domain_db = 0;
741 const char* path = 0;741 const char* path = 0;
742 const char* path_db = 0;742 const char* path_db = 0;
743 const char* back_link = 0;
743 char* query = 0;744 char* query = 0;
744 apr_dbd_results_t* res = 0;745 apr_dbd_results_t* res = 0;
745 apr_dbd_row_t* row = 0;746 apr_dbd_row_t* row = 0;
@@ -766,7 +767,7 @@
766 return 0;767 return 0;
767 }768 }
768769
769 query = apr_pstrdup(p, "SELECT domain, path, user_agent_string FROM useragent ORDER BY id DESC");770 query = apr_pstrdup(p, "SELECT domain, path, user_agent_string, back_link FROM useragent ORDER BY id DESC");
770771
771 if (error = apr_dbd_select(dbd->driver,p,dbd->handle, &res, query, 0))772 if (error = apr_dbd_select(dbd->driver,p,dbd->handle, &res, query, 0))
772 {773 {
@@ -802,9 +803,13 @@
802 {803 {
803 match_length_so_far = match_length;804 match_length_so_far = match_length;
804 user_agent_string = apr_pstrdup(p, apr_dbd_get_entry(dbd->driver, row, 2));805 user_agent_string = apr_pstrdup(p, apr_dbd_get_entry(dbd->driver, row, 2));
806 back_link = apr_pstrdup(p, apr_dbd_get_entry(dbd->driver, row, 3));
805 }807 }
806 }808 }
807809 if (back_link && *back_link)
810 {
811 apr_table_set(r->subprocess_env, "psiphon_custom_user_agent_back_link", back_link);
812 }
808 return user_agent_string;813 return user_agent_string;
809}814}
810815
@@ -861,6 +866,7 @@
861 {866 {
862 /* If we found a non 0 length user agent string, then set the custom user agent */867 /* If we found a non 0 length user agent string, then set the custom user agent */
863 apr_table_set(r->headers_in, "User-Agent", user_agent_string);868 apr_table_set(r->headers_in, "User-Agent", user_agent_string);
869 apr_table_set(r->subprocess_env, "psiphon_custom_user_agent", user_agent_string);
864 }870 }
865871
866 /* Add cookies headers from DB for authenticated user*/872 /* Add cookies headers from DB for authenticated user*/
867873
=== added file 'trunk/sql/upgrade-2.6.sql'
--- trunk/sql/upgrade-2.6.sql 1970-01-01 00:00:00 +0000
+++ trunk/sql/upgrade-2.6.sql 2010-09-01 14:48:14 +0000
@@ -0,0 +1,4 @@
1--
2-- Modifications to table useragent for handling compatibility mode exit link
3--
4ALTER TABLE useragent ADD back_link text;
05
=== modified file 'trunk/tools/psiphon_install.sh'
--- trunk/tools/psiphon_install.sh 2010-06-01 17:50:42 +0000
+++ trunk/tools/psiphon_install.sh 2010-09-01 14:48:14 +0000
@@ -271,7 +271,7 @@
271echo "Enter current password for mysql root (enter for none)"271echo "Enter current password for mysql root (enter for none)"
272272
273cat sql/create_db.sql sql/grant.new.sql sql/structure.2.3.sql sql/init.sql \273cat sql/create_db.sql sql/grant.new.sql sql/structure.2.3.sql sql/init.sql \
274sql/upgrade-2.4.sql sql/upgrade-2.5.sql sql/jsf.sql sql/youtube.sql | mysql -uroot -p274sql/upgrade-2.4.sql sql/upgrade-2.5.sql sql/upgrade-2.6.sql sql/jsf.sql sql/youtube.sql | mysql -uroot -p
275275
276rm sql/grant.new.sql276rm sql/grant.new.sql
277277
278278
=== modified file 'trunk/www/bluebar.php'
--- trunk/www/bluebar.php 2010-07-14 20:51:28 +0000
+++ trunk/www/bluebar.php 2010-09-01 14:48:14 +0000
@@ -65,7 +65,6 @@
65 !strncmp($uri, "https://", 8))) {65 !strncmp($uri, "https://", 8))) {
66 $uri="";66 $uri="";
67}67}
68
69?>68?>
7069
71<!--bluebar-->70<!--bluebar-->
@@ -82,6 +81,12 @@
82<?81<?
83echo $v;82echo $v;
8483
84// Indicate custom user agent, if it configured for the proxied URL
85
86if (isset($_SERVER["psiphon_custom_user_agent"]) && isset($_SERVER["psiphon_custom_user_agent_back_link"])) {
87 echo "<a href=\"".$prefix."/".$_SERVER["psiphon_custom_user_agent_back_link"]."\" target=\"_top\">".utf8_encode_string(msg("exit_compatibility_mode"))."</a> |\n";
88}
89
85// Add link create for Anonymous Users90// Add link create for Anonymous Users
8691
87if (is_anonymous_user($record_user))92if (is_anonymous_user($record_user))
8893
=== modified file 'trunk/www/custom_user_agent.php'
--- trunk/www/custom_user_agent.php 2010-06-28 20:26:25 +0000
+++ trunk/www/custom_user_agent.php 2010-09-01 14:48:14 +0000
@@ -39,8 +39,8 @@
39if ($_POST['id']=="add")39if ($_POST['id']=="add")
40{40{
41 $query =41 $query =
42 "INSERT INTO useragent (domain, path, user_agent_string) ".42 "INSERT INTO useragent (domain, path, user_agent_string, back_link) ".
43 "VALUES (:domain, :path, :user_agent_string)";43 "VALUES (:domain, :path, :user_agent_string, :back_link)";
44 44
45 db_query_execute(45 db_query_execute(
46 $config,46 $config,
@@ -48,7 +48,9 @@
48 convert_null_array(array(48 convert_null_array(array(
49 ":domain" => $_POST['domain'],49 ":domain" => $_POST['domain'],
50 ":path" => $_POST['path'],50 ":path" => $_POST['path'],
51 ":user_agent_string" => $_POST['user_agent_string'])));51 ":user_agent_string" => $_POST['user_agent_string'],
52 ":back_link" => $_POST['back_link']
53 )));
52 54
53 $last = db_get_last_insert_id($config);55 $last = db_get_last_insert_id($config);
54}56}
@@ -62,7 +64,8 @@
62 "UPDATE useragent SET ".64 "UPDATE useragent SET ".
63 "domain = :domain, ".65 "domain = :domain, ".
64 "path = :path, ".66 "path = :path, ".
65 "user_agent_string = :user_agent_string ".67 "user_agent_string = :user_agent_string, ".
68 "back_link = :back_link ".
66 "WHERE id = :id";69 "WHERE id = :id";
6770
68 db_query_execute(71 db_query_execute(
@@ -72,6 +75,7 @@
72 ":domain" => $_POST['domain'],75 ":domain" => $_POST['domain'],
73 ":path" => $_POST['path'],76 ":path" => $_POST['path'],
74 ":user_agent_string" => $_POST['user_agent_string'],77 ":user_agent_string" => $_POST['user_agent_string'],
78 ":back_link" => $_POST['back_link'],
75 ":id" => $_POST['id'])));79 ":id" => $_POST['id'])));
76 80
77 $last = $_POST['id'];81 $last = $_POST['id'];
@@ -123,6 +127,11 @@
123 <?=msg("user_agent_string")?>127 <?=msg("user_agent_string")?>
124 <br>128 <br>
125 <textarea name="user_agent_string" cols="60" rows="5"><?=escape_html($_POST['user_agent_string'])?></textarea>129 <textarea name="user_agent_string" cols="60" rows="5"><?=escape_html($_POST['user_agent_string'])?></textarea>
130
131 <br>
132 <?=msg("back_link")?>
133 <br>
134 <textarea name="back_link" cols="60" rows="2"><?=escape_html($_POST['back_link'])?></textarea>
126 </td>135 </td>
127136
128 <td>137 <td>
@@ -159,8 +168,8 @@
159 echo "<td colspan=\"3\">\n<input type=\"hidden\" name=\"id\" value=\"{$record['id']}\" />\n";168 echo "<td colspan=\"3\">\n<input type=\"hidden\" name=\"id\" value=\"{$record['id']}\" />\n";
160 echo msg("domain")."\n<br>\n<input type=\"text\" name=\"domain\" maxlength=\"64\" size=\"20\" value=\"".$record['domain']."\" />\n<br>\n";169 echo msg("domain")."\n<br>\n<input type=\"text\" name=\"domain\" maxlength=\"64\" size=\"20\" value=\"".$record['domain']."\" />\n<br>\n";
161 echo msg("path")."\n<br>\n<input type=\"text\" name=\"path\" maxlength=\"255\" size=\"60\" value=\"".$record['path']."\" />\n<br>\n";170 echo msg("path")."\n<br>\n<input type=\"text\" name=\"path\" maxlength=\"255\" size=\"60\" value=\"".$record['path']."\" />\n<br>\n";
162171 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";
163 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";172 echo msg("back_link")."\n<br>\n<textarea name=\"back_link\" cols=\"60\" rows=\"2\">\n".$record['back_link']."</textarea>\n</td>\n";
164173
165 echo "<td>{$_p}<input type=\"submit\" value=\"".msg("save")."\" /> &nbsp; <a href=\"".getenv("SCRIPT_NAME")."?fresh={$fresh}\">".msg("cancel")."</a>{$_s}</td>\n";174 echo "<td>{$_p}<input type=\"submit\" value=\"".msg("save")."\" /> &nbsp; <a href=\"".getenv("SCRIPT_NAME")."?fresh={$fresh}\">".msg("cancel")."</a>{$_s}</td>\n";
166 }175 }
167176
=== modified file 'trunk/www/includes/lang.php'
--- trunk/www/includes/lang.php 2010-08-09 18:56:53 +0000
+++ trunk/www/includes/lang.php 2010-09-01 14:48:14 +0000
@@ -4630,6 +4630,33 @@
4630Please begin using this URL to log into Psiphon.",4630Please begin using this URL to log into Psiphon.",
4631 ),4631 ),
46324632
4633 'exit_compatibility_mode' => array(
4634 'en' => "Exit Compatibility Mode",
4635 'fa' => "Exit Compatibility Mode",
4636 'ru' => "Exit Compatibility Mode",
4637 'uz' => "Exit Compatibility Mode",
4638 'tk' => "Exit Compatibility Mode",
4639 'cn' => "Exit Compatibility Mode",
4640 'ar' => "Exit Compatibility Mode",
4641 'vt' => "Exit Compatibility Mode",
4642 'fr' => "Exit Compatibility Mode",
4643 'es' => "Exit Compatibility Mode",
4644 ),
4645
4646 'back_link' => array(
4647 'en' => "Exit Compatibility Mode link",
4648 'fa' => "Exit Compatibility Mode link",
4649 'ru' => "Exit Compatibility Mode link",
4650 'uz' => "Exit Compatibility Mode link",
4651 'tk' => "Exit Compatibility Mode link",
4652 'cn' => "Exit Compatibility Mode link",
4653 'ar' => "Exit Compatibility Mode link",
4654 'vt' => "Exit Compatibility Mode link",
4655 'fr' => "Exit Compatibility Mode link",
4656 'es' => "Exit Compatibility Mode link",
4657 ),
4658
4659
4633// DO NOT MODIFY THIS LINE -- END OF TRANSLATIONS4660// DO NOT MODIFY THIS LINE -- END OF TRANSLATIONS
4634);4661);
46354662

Subscribers

People subscribed via source and target branches