[FIX] link_tracker: page title encoding
When tracking a page with special characters in the title (e.g. `Ä`), the title of the page in the tracked links was badly encoded, because the encoding was not handled correctly when parsing the given website page. opw-679993
This commit is contained in:
@@ -4,13 +4,14 @@ import random
|
||||
import re
|
||||
import string
|
||||
|
||||
from lxml.html import parse
|
||||
from lxml import html
|
||||
from urllib2 import urlopen
|
||||
from urlparse import urljoin
|
||||
from urlparse import urlparse
|
||||
from werkzeug import url_encode
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
from openerp.tools import ustr
|
||||
|
||||
URL_REGEX = r'(\bhref=[\'"](?!mailto:)([^\'"]+)[\'"])'
|
||||
|
||||
@@ -108,7 +109,7 @@ class link_tracker(models.Model):
|
||||
def _get_title_from_url(self, url):
|
||||
try:
|
||||
page = urlopen(url, timeout=5)
|
||||
p = parse(page)
|
||||
p = html.fromstring(ustr(page.read()).encode('utf-8'), parser=html.HTMLParser(encoding='utf-8'))
|
||||
title = p.find('.//title').text
|
||||
except:
|
||||
title = url
|
||||
|
||||
Reference in New Issue
Block a user