[kupfer] websearch: Only use Url tags with type=text/html



commit ff6ad4f4dd2cc352b90831212de0c5efdb5ce8e7
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Wed Mar 2 16:46:28 2011 +0100

    websearch: Only use Url tags with type=text/html
    
    Our parser picked up on unwanted Url fields if they were listed later
    in the file, they would overwrite the wanted (text/html) Url field.
    
    Launchpad-bug: https://bugs.launchpad.net/kupfer/+bug/682476

 kupfer/plugin/websearch.py |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/kupfer/plugin/websearch.py b/kupfer/plugin/websearch.py
index 139f109..8c5a8b2 100644
--- a/kupfer/plugin/websearch.py
+++ b/kupfer/plugin/websearch.py
@@ -130,15 +130,19 @@ class OpenSearchSource (Source):
 				tagname = gettagname(child.tag)
 				if tagname not in keys:
 					continue
-				if (tagname == "Url" and child.get("type") == "text/html" and
+				# Only pick up Url tags with type="text/html"
+				if tagname == "Url":
+					if (child.get("type") == "text/html" and
 						child.get("template")):
-					text = child.get("template")
-					params = {}
-					for ch in child.getchildren():
-						if gettagname(ch.tag) == "Param":
-							params[ch.get("name")] = ch.get("value")
-					if params:
-						text += _noescape_urlencode(params.items())
+						text = child.get("template")
+						params = {}
+						for ch in child.getchildren():
+							if gettagname(ch.tag) == "Param":
+								params[ch.get("name")] = ch.get("value")
+						if params:
+							text += _noescape_urlencode(params.items())
+					else:
+						continue
 				else:
 					text = (child.text or "").strip()
 				search[tagname] = text



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]