Merge lp:~ken-vandine/unity-lens-friends/libunity7-compatible_strip_links into lp:~unity-team/unity-lens-friends/libunity7-compatible

Proposed by Ken VanDine
Status: Merged
Approved by: Ken VanDine
Approved revision: 58
Merged at revision: 57
Proposed branch: lp:~ken-vandine/unity-lens-friends/libunity7-compatible_strip_links
Merge into: lp:~unity-team/unity-lens-friends/libunity7-compatible
Diff against target: 97 lines (+24/-7)
3 files modified
debian/changelog (+12/-4)
debian/control (+1/-0)
src/daemon.vala (+11/-3)
To merge this branch: bzr merge lp:~ken-vandine/unity-lens-friends/libunity7-compatible_strip_links
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+155570@code.launchpad.net

Commit message

strip links from content, the lens can't render them

Description of the change

strip links from content, the lens can't render them

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
58. By Ken VanDine

simplified regex

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Bruce Park (robru) wrote :

Nice, simple regex. I like it ;-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-03-22 18:22:23 +0000
3+++ debian/changelog 2013-03-27 00:39:23 +0000
4@@ -1,7 +1,4 @@
5-unity-lens-friends (0.1.1bzr13.03.14-0ubuntu1) UNRELEASED; urgency=low
6-
7- [ Ken VanDine ]
8- * Ported to the flatter schema
9+unity-lens-friends (0.1.1bzr13.03.26-0ubuntu1) UNRELEASED; urgency=low
10
11 [ James Henstridge ]
12 * Require new libunity.
13@@ -11,8 +8,19 @@
14 * transition from gwibber lens to the friends one
15 * Automatic snapshot from revision 43 (boostrap)
16
17+ [ Ken VanDine ]
18+ * strip links from content, the lens can't render them
19+
20 -- Ken VanDine <ken.vandine@canonical.com> Thu, 14 Mar 2013 10:12:48 -0400
21
22+unity-lens-friends (0.1.1bzr13.03.20-0ubuntu1) raring; urgency=low
23+
24+ * Ported to the flatter schema (LP: #1156941)
25+ * debian/control
26+ - depend on friends (>= 0.1.3) for schema changes (LP: #1156941)
27+
28+ -- Ken VanDine <ken.vandine@canonical.com> Wed, 20 Mar 2013 15:46:20 -0400
29+
30 unity-lens-friends (0.1.1bzr13.02.25-0ubuntu1) raring; urgency=low
31
32 * Dropped src/stream-model-schema.vala, the schema is defined
33
34=== modified file 'debian/control'
35--- debian/control 2013-03-22 08:09:33 +0000
36+++ debian/control 2013-03-27 00:39:23 +0000
37@@ -21,6 +21,7 @@
38 Architecture: any
39 Depends: ${shlibs:Depends},
40 ${misc:Depends},
41+ friends (>= 0.1.3),
42 Conflicts: unity-lens-gwibber,
43 Provides: unity-lens-gwibber,
44 Replaces: unity-lens-gwibber,
45
46=== modified file 'src/daemon.vala'
47--- src/daemon.vala 2013-03-22 06:41:51 +0000
48+++ src/daemon.vala 2013-03-27 00:39:23 +0000
49@@ -27,6 +27,7 @@
50 /* DBus name for the place. Must match out .place file */
51 const string BUS_NAME = "com.canonical.Unity.Scope.Friends";
52 const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/places/svg/";
53+ const string STRIP_LINKS = """</?a[^>]*>""";
54
55 /**
56 * The Daemon class implements all of the logic for the place.
57@@ -520,7 +521,7 @@
58 ResultType.PERSONAL,
59 "text/html",
60 GLib.Markup.escape_text (_model.get_string(iter, StreamModelColumn.SENDER)),
61- _model.get_string(iter, StreamModelColumn.MESSAGE),
62+ sanitize_message (_model.get_string(iter, StreamModelColumn.MESSAGE)),
63 uri,
64 empty_asv);
65 }
66@@ -582,7 +583,7 @@
67 var likes = model.get_uint64 (iter, StreamModelColumn.LIKES);
68 var sender = model.get_string (iter, StreamModelColumn.SENDER);
69 var timestring = utils.create_time_string (model.get_string (iter, StreamModelColumn.TIMESTAMP));
70- var content = model.get_string (iter, StreamModelColumn.MESSAGE);
71+ var content = sanitize_message (_model.get_string(iter, StreamModelColumn.MESSAGE));
72 string title = timestring;
73 preview = new Unity.SocialPreview (sender, title, content, avatar);
74 // work around bug 1058198
75@@ -691,6 +692,13 @@
76 return preview;
77 }
78
79+ private string sanitize_message (string msg)
80+ {
81+ var remove_links_regex = new Regex (STRIP_LINKS, RegexCompileFlags.CASELESS);
82+ string _msg_cleaned = remove_links_regex.replace (msg, msg.length, 0, "");
83+ return _msg_cleaned;
84+ }
85+
86 private void parse_comments (Unity.SocialPreview preview, string _message_id)
87 {
88 if (_message_id != null)
89@@ -706,7 +714,7 @@
90 if (_stream == _message_id)
91 {
92 debug ("stream: %s", _stream);
93- var text = _model.get_string (iter, StreamModelColumn.MESSAGE);
94+ var text = sanitize_message (_model.get_string (iter, StreamModelColumn.MESSAGE));
95 var name = GLib.Markup.escape_text (_model.get_string (iter, StreamModelColumn.SENDER));
96 var time_string = utils.create_time_string (_model.get_string (iter, StreamModelColumn.TIMESTAMP));
97 preview.add_comment (new Unity.SocialPreview.Comment (name, name, text, time_string));

Subscribers

People subscribed via source and target branches

to all changes: