From bc1981a07ade876c1bca7e965c058854d799bad4 Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Fri, 15 Jun 2007 17:29:24 +0000
Subject: [PATCH] Tweaking beautiful soup to get rid of some exceptions.  -
 Legacy-Id: 414

---
 ietf/contrib/BeautifulSoup.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ietf/contrib/BeautifulSoup.py b/ietf/contrib/BeautifulSoup.py
index 4627102a9..7bffc2b38 100644
--- a/ietf/contrib/BeautifulSoup.py
+++ b/ietf/contrib/BeautifulSoup.py
@@ -335,10 +335,10 @@ class PageElement:
         ."""
         if isinstance(s, unicode):
             if encoding:
-                s = s.encode(encoding)
+                s = s.encode(encoding, 'xmlcharrefreplace')
         elif isinstance(s, str):
             if encoding:
-                s = s.encode(encoding)
+                s = s.encode(encoding, 'xmlcharrefreplace')
             else:
                 s = unicode(s)
         else:
@@ -364,7 +364,7 @@ class NavigableString(unicode, PageElement):
 
     def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING):
         if encoding:
-            return self.encode(encoding)
+            return self.encode(encoding, 'xmlcharrefreplace')
         else:
             return self