From 0539a4d4deec54b8d3ab830dc9c067b76dd00d2e Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Wed, 16 Mar 2011 21:36:10 +0000 Subject: html entities are now converted to utf-8 strings before the submission to the server --- h-client/hlibrary.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'h-client/hlibrary.py') 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): -- cgit v1.2.3