Skip to content
Snippets Groups Projects
Commit 4e1ad1cc authored by Pavel Kácha's avatar Pavel Kácha
Browse files

Python 3 str/bytes compatibility fixes

parent 38872f06
No related branches found
No related tags found
No related merge requests found
...@@ -6,14 +6,16 @@ from collections import Sequence, Mapping ...@@ -6,14 +6,16 @@ from collections import Sequence, Mapping
from base64 import b64decode from base64 import b64decode
from uuid import uuid4 from uuid import uuid4
if version_info >= (3, 0): if version_info >= (3, 0):
from urllib.parse import quote_plus as quot from urllib.parse import quote_plus
basestring = str basestring = str
else: else:
from urllib import quote_plus as quot from urllib import quote_plus
from intelmq.lib.bot import Bot from intelmq.lib.bot import Bot
from intelmq.lib.message import Event from intelmq.lib.message import Event
def quot(s):
return quote_plus((s or "").encode("UTF-8"))
def get_value(src, value): def get_value(src, value):
try: try:
...@@ -133,7 +135,7 @@ translation = { ...@@ -133,7 +135,7 @@ translation = {
"Ref": [lambda s: "malware:" + quot(s["malware.name"] + quot(s.get("malware.version")))] "Ref": [lambda s: "malware:" + quot(s["malware.name"] + quot(s.get("malware.version")))]
}, },
{ {
"Content": lambda s: b64decode(s["raw"]), "Content": lambda s: b64decode(s["raw"]).decode("ISO-8859-1"),
"Type": [lambda s: s["raw"] and "OrigData"], "Type": [lambda s: s["raw"] and "OrigData"],
"Ref": ["feed.url"] "Ref": ["feed.url"]
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment