[deskbar-applet] Unescape HTML entities in Google Search and Google Code Search module.
- From: Sebastian Polsterl <sebp src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [deskbar-applet] Unescape HTML entities in Google Search and Google Code Search module.
- Date: Sun, 1 Nov 2009 13:01:18 +0000 (UTC)
commit 0847cfd62340f4f9483878398a829380b3d57473
Author: Sebastian Pölsterl <sebp k-d-w org>
Date: Sun Nov 1 13:59:01 2009 +0100
Unescape HTML entities in Google Search and Google Code Search module.
Fixes bug #555713.
deskbar/handlers/googlecodesearch.py | 19 ++++++++++++-------
deskbar/handlers/googlesearch.py | 6 +++---
2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/deskbar/handlers/googlecodesearch.py b/deskbar/handlers/googlecodesearch.py
index 4431560..19e0e49 100644
--- a/deskbar/handlers/googlecodesearch.py
+++ b/deskbar/handlers/googlecodesearch.py
@@ -1,10 +1,9 @@
-from deskbar.core.Utils import strip_html, get_proxy
+from deskbar.core.Utils import strip_html, get_proxy, htmldecode
from deskbar.defs import VERSION
from deskbar.handlers.actions.CopyToClipboardAction import CopyToClipboardAction
from deskbar.handlers.actions.ShowUrlAction import ShowUrlAction
from gettext import gettext as _
from os.path import basename
-from xml.sax.saxutils import unescape
import deskbar
import deskbar.interfaces.Match
import deskbar.interfaces.Module
@@ -37,7 +36,7 @@ class GoogleCodeSearchModule(deskbar.interfaces.Module):
Remove HTML tags and display only the first line
that contains the search term
"""
- content_lines = strip_html(content).split("\n")
+ content_lines = strip_html(htmldecode(content)).split("\n")
pattern = re.escape(qstring)
new_content = ""
for content in content_lines:
@@ -47,9 +46,9 @@ class GoogleCodeSearchModule(deskbar.interfaces.Module):
content.strip(),
re.IGNORECASE | re.MULTILINE)
new_content += "\n"
-
+
if len(new_content) > 0:
- return new_content.strip()
+ return new_content.strip().replace("&", "&")
else:
return None
@@ -125,6 +124,12 @@ class GoToPackageLocationAction(ShowUrlAction):
def get_verb(self):
return _("Open package <i>%(name)s</i>")
+ def is_valid(self):
+ if self._url.startswith("ftp://"):
+ return True
+ else:
+ return ShowUrlAction.is_valid(self)
+
class SearchWithGoogleCodeAction(ShowUrlAction):
"""
Open the Google Codesearch page with results
@@ -190,7 +195,7 @@ class GoogleCodeSearchFeedParser(xml.sax.handler.ContentHandler):
value = self.__contents.strip()
if len(value) == 0:
value = None
- self.__entry[key] = unescape(value)
+ self.__entry[key] = value
self._reset_contents()
def get_results(self):
@@ -235,4 +240,4 @@ class GoogleCodeSearchFeedParser(xml.sax.handler.ContentHandler):
def characters(self, content):
if not self.__not_interested:
self.__contents += content
-
\ No newline at end of file
+
diff --git a/deskbar/handlers/googlesearch.py b/deskbar/handlers/googlesearch.py
index c7334db..19cc7d0 100644
--- a/deskbar/handlers/googlesearch.py
+++ b/deskbar/handlers/googlesearch.py
@@ -1,5 +1,5 @@
from deskbar.core.GconfStore import GconfStore
-from deskbar.core.Utils import strip_html, get_proxy, get_locale_lang
+from deskbar.core.Utils import strip_html, get_proxy, get_locale_lang, htmldecode
from deskbar.defs import VERSION
from deskbar.handlers.actions.CopyToClipboardAction import CopyToClipboardAction
from deskbar.handlers.actions.ShowUrlAction import ShowUrlAction
@@ -208,9 +208,9 @@ class OpenGoogleAction(ShowUrlAction):
class GoogleMatch(deskbar.interfaces.Match):
def __init__(self, result=None, **args):
deskbar.interfaces.Match.__init__(self, category="web", icon="google.png", **args)
- self._name = result['titleNoFormatting']
+ self._name = htmldecode(result['titleNoFormatting'])
self.url = result['url']
- self.set_snippet(result['content'])
+ self.set_snippet(htmldecode(result['content']))
self.add_action( OpenGoogleAction(self.get_name(), self.url) )
self.add_action( CopyToClipboardAction( _("URL"), self.url) )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]