aboutsummaryrefslogtreecommitdiff
path: root/h-client/hlibrary.py
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-03-16 21:36:10 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-03-16 21:36:10 +0000
commit0539a4d4deec54b8d3ab830dc9c067b76dd00d2e (patch)
tree7218a2534e189ecf303d42d1c867ed4220ff814e /h-client/hlibrary.py
parent4951c1f4dfdf6021729a5097052251d5b0a28a6c (diff)
html entities are now converted to utf-8 strings before the submission to the server
Diffstat (limited to 'h-client/hlibrary.py')
-rw-r--r--h-client/hlibrary.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index 1a86d81..c763a76 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -22,6 +22,7 @@ import re
import sys
import pycurl
import urllib
+import htmlentitydefs
from xml.dom import minidom
@@ -80,9 +81,14 @@ class Device(object):
self._post['comm_year'] = self._year;
self._post['pci_id'] = self._vendorId + ':' + self._productId;
self._post['interface'] = self._interface;
- self._post['description'] = self._description;
+ self._post['description'] = self.htmlentitiesDecode(self._description.replace("\n","\r\n"));
self._post['driver'] = self._driver;
+ #replace the HTML entitites with utf-8 characters
+ def htmlentitiesDecode(self,string):
+ for entity,code in htmlentitydefs.name2codepoint.iteritems():
+ string = string.replace("&"+entity+";",unichr(code))
+ return string.encode('utf-8')
#get the distro h-source allowed code from the distro codename
def getDistroCode(self,codenameString):