1.1 --- a/vContent.py Mon Oct 30 23:14:45 2017 +0100
1.2 +++ b/vContent.py Fri Nov 24 16:59:33 2017 +0100
1.3 @@ -4,7 +4,7 @@
1.4 Parsing of vCard, vCalendar and iCalendar files.
1.5
1.6 Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011, 2013,
1.7 - 2014, 2015 Paul Boddie <paul@boddie.org.uk>
1.8 + 2014, 2015, 2017 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -280,9 +280,12 @@
1.13
1.14 return self.parse_content_line()
1.15
1.16 - def decode_content(self, value):
1.17 + def decode_content(self, name, value):
1.18
1.19 - "Decode the given 'value', replacing quoted characters."
1.20 + """
1.21 + Decode for property 'name' the given 'value', replacing quoted
1.22 + characters.
1.23 + """
1.24
1.25 return value.replace("\r", "").replace("\\N", "\n").replace("\\n", "\n")
1.26
1.27 @@ -346,7 +349,7 @@
1.28 encoding = parameters.get("ENCODING")
1.29 charset = parameters.get("CHARSET")
1.30
1.31 - value = self.decode_content(value)
1.32 + value = self.decode_content(name, value)
1.33
1.34 if encoding == "QUOTED-PRINTABLE":
1.35 return unicode(quopri.decodestring(value), charset or "iso-8859-1")
1.36 @@ -582,7 +585,7 @@
1.37 elif encoding == "BASE64":
1.38 value = base64.encodestring(value)
1.39
1.40 - return self.encode_content(value)
1.41 + return self.encode_content(name, value)
1.42 except TypeError:
1.43 raise WriteError, "Property %r value with parameters %r cannot be encoded: %r" % (name, parameters, value)
1.44
1.45 @@ -609,9 +612,9 @@
1.46
1.47 return encoded_parameters
1.48
1.49 - def encode_content(self, value):
1.50 + def encode_content(self, name, value):
1.51
1.52 - "Encode the given 'value', quoting characters."
1.53 + "Encode for property 'name' the given 'value', quoting characters."
1.54
1.55 return (value or "").replace("\n", "\\n")
1.56