New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] website_lazy_load_image: HTML parsing #651
Conversation
d618894
to
c3b23d5
Compare
@oscarolar could you review this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c3b23d5
to
20adf47
Compare
@simahawk Thanks for your feedback! I committed your changes proposed at #571 (comment) html = ehtml.fromstring(res.decode()) What do you think? |
@@ -2,7 +2,7 @@ | |||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | |||
|
|||
from odoo import api, models | |||
from lxml import etree | |||
from lxml import html as ehtml, etree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just import lxml use lxml.etree
and lxml.html
@@ -22,7 +22,7 @@ def render_template(self, template, values=None, engine='ir.qweb'): | |||
website_id = self.env.context.get('website_id') | |||
if website_id and not \ | |||
self.env['website'].browse(website_id).is_publisher(): | |||
html = etree.HTML(res) | |||
html = ehtml.fromstring(res.decode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I don't understand: where is the check on whether this is or not an HTML source? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you mentioned, lxml.html.fromstring keep the content as it's if it's not an html content.
I just tested it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I didn't face any problem with robots.txt as mentioned on the issue #551
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, cool! Can you update tests here to avoid regressions?
html.fromstring function. Before this commit, the render_template has an issue with views retrieved from a controller, like the wizard of event detail registration, the content was wrapped into an html DOM, this leads a wrong modal behavior. FIX OCA#551
20adf47
to
0b8d011
Compare
@simahawk |
9eaaac6
to
32acf5e
Compare
9268e7a
to
2a84a7c
Compare
2a84a7c
to
00edff0
Compare
@tarteo could you review please |
00edff0
to
a6d9ce9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks!
@oscarolar |
This PR has the |
@yajo could you merge please |
/ocabot merge minor |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 36dc3cc. Thanks a lot for contributing to OCA. ❤️ PS: Don't worry if GitHub says there are unmerged commits: it is due to a rebase before merge. All commits of this PR have been merged into |
fromstring function.
Before this commit, the render_template has an issue with views retrieved
from a controller, like the wizard of event detail registration, the
the content was introduced into an html DOM, this leads a wrong modal
behavior.
Now the first attempt is with fromstring function if fails, then use
the original process with html function.
Before
After
Before
After