From 759ca69205d6caaa3176e14a123d89fdd57c7edf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 12 Mar 2009 10:11:41 -0700 Subject: [PATCH] Fix #2041 (Error fetching news la repubblica on MacOSX) --- src/calibre/ebooks/BeautifulSoup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/BeautifulSoup.py b/src/calibre/ebooks/BeautifulSoup.py index 24cd5fe3dd..cb2fe950fd 100644 --- a/src/calibre/ebooks/BeautifulSoup.py +++ b/src/calibre/ebooks/BeautifulSoup.py @@ -1306,7 +1306,10 @@ class BeautifulStoneSoup(Tag, SGMLParser): if self.convertEntities: if ref.lower().startswith('x'): # ref = int(ref[1:], 16) # Added by Kovid to handle hex numeric entities - data = unichr(int(ref)) + try: + data = unichr(int(ref)) + except ValueError: # Bad numerical entity. Added by Kovid + data = u'' else: data = '&#%s;' % ref self.handle_data(data)