diff --git a/src/calibre/ebooks/oeb/parse_utils.py b/src/calibre/ebooks/oeb/parse_utils.py
index 3b50301a5b..712427d457 100644
--- a/src/calibre/ebooks/oeb/parse_utils.py
+++ b/src/calibre/ebooks/oeb/parse_utils.py
@@ -81,7 +81,7 @@ def node_depth(node):
def html5_parse(data, max_nesting_depth=100):
import html5lib
# html5lib bug: http://code.google.com/p/html5lib/issues/detail?id=195
- data = re.sub(r'<\s*title\s*/\s*>', '
', data)
+ data = re.sub(r'<\s*title\s*[^>]*/\s*>', '', data)
data = html5lib.parse(data, treebuilder='lxml').getroot()
diff --git a/src/calibre/ebooks/pml/input.py b/src/calibre/ebooks/pml/input.py
index 91cd457c27..4d59668b12 100644
--- a/src/calibre/ebooks/pml/input.py
+++ b/src/calibre/ebooks/pml/input.py
@@ -47,7 +47,8 @@ class PMLInput(InputFormatPlugin):
self.log.debug('Converting PML to HTML...')
hizer = PML_HTMLizer()
html = hizer.parse_pml(pml_stream.read().decode(ienc), html_path)
- html_stream.write('%s' % html.encode('utf-8', 'replace'))
+ html = '%s'%html
+ html_stream.write(html.encode('utf-8', 'replace'))
if pclose:
pml_stream.close()