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] web_editor: upload CORS images by URL #160085
[FIX] web_editor: upload CORS images by URL #160085
Conversation
4145f37
to
d01ed5e
Compare
The fix looks ok to fallback to the old behavior. 👍 |
Indeed.. I think we did not do that because we did not want the server to contact another random server that any of our client can ask us to. About the steps to reproduce, note that the image you provided doesn't work on my side (it doesn't let me go through the media dialog). I still reproduced it using any other cors protected image tho. |
d01ed5e
to
def179c
Compare
After re-testing, I notice I misunderstood this during my first review. This is actually happening during record save - therefore at upload, which is good news. |
def179c
to
12dd433
Compare
d8a5da4
to
dcd38d1
Compare
- Install E-commerce app - Go to Website > Shop, and open a product - Click on edit on the upper right corner. - Double click the product image to change it. A popup is shown. - In the popup, click on Add URL and place this URL [1] - Click Save. The image disappears! - The issue was introduced here [2] - As URL now starts with `/web/image/` which will be later used here [3] - The condition to enter this line is `url_object.path.startswith('/web/image')` - `item[field]` is used which equals to `attachment[datas]` - But actually `datas` is empty as the image upload fails because of CORS - `add_url` is called [4] saving attachment without `datas` but with type URL - The commit solves the issue by fetching the remote data from the server if the url is a remote redirection, which still happens when the image data cannot be fetched by the client browser at upload time. [1]: https://lowendbox.com/wp-content/uploads/2022/09/odoo_logo_1200.png [2]: odoo@943944d#diff-0897c80484208197b0aff67f2b06509e864c3976de1589e3cebad2788eef008fR49 [3]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/models/ir_qweb_fields.py#L473 [4]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/controllers/main.py#L268 opw-3746245
557e73b
to
bc74671
Compare
@robodoo r+ |
- Install E-commerce app - Go to Website > Shop, and open a product - Click on edit on the upper right corner. - Double click the product image to change it. A popup is shown. - In the popup, click on Add URL and place this URL [1] - Click Save. The image disappears! - The issue was introduced here [2] - As URL now starts with `/web/image/` which will be later used here [3] - The condition to enter this line is `url_object.path.startswith('/web/image')` - `item[field]` is used which equals to `attachment[datas]` - But actually `datas` is empty as the image upload fails because of CORS - `add_url` is called [4] saving attachment without `datas` but with type URL - The commit solves the issue by fetching the remote data from the server if the url is a remote redirection, which still happens when the image data cannot be fetched by the client browser at upload time. [1]: https://lowendbox.com/wp-content/uploads/2022/09/odoo_logo_1200.png [2]: 943944d#diff-0897c80484208197b0aff67f2b06509e864c3976de1589e3cebad2788eef008fR49 [3]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/models/ir_qweb_fields.py#L473 [4]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/controllers/main.py#L268 opw-3746245 closes #160085 Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
- Install E-commerce app - Go to Website > Shop, and open a product - Click on edit on the upper right corner. - Double click the product image to change it. A popup is shown. - In the popup, click on Add URL and place this URL [1] - Click Save. The image disappears! - The issue was introduced here [2] - As URL now starts with `/web/image/` which will be later used here [3] - The condition to enter this line is `url_object.path.startswith('/web/image')` - `item[field]` is used which equals to `attachment[datas]` - But actually `datas` is empty as the image upload fails because of CORS - `add_url` is called [4] saving attachment without `datas` but with type URL - The commit solves the issue by fetching the remote data from the server if the url is a remote redirection, which still happens when the image data cannot be fetched by the client browser at upload time. [1]: https://lowendbox.com/wp-content/uploads/2022/09/odoo_logo_1200.png [2]: 943944d#diff-0897c80484208197b0aff67f2b06509e864c3976de1589e3cebad2788eef008fR49 [3]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/models/ir_qweb_fields.py#L473 [4]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/controllers/main.py#L268 opw-3746245 closes #160085 Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
- Install E-commerce app - Go to Website > Shop, and open a product - Click on edit on the upper right corner. - Double click the product image to change it. A popup is shown. - In the popup, click on Add URL and place this URL [1] - Click Save. The image disappears! - The issue was introduced here [2] - As URL now starts with `/web/image/` which will be later used here [3] - The condition to enter this line is `url_object.path.startswith('/web/image')` - `item[field]` is used which equals to `attachment[datas]` - But actually `datas` is empty as the image upload fails because of CORS - `add_url` is called [4] saving attachment without `datas` but with type URL - The commit solves the issue by fetching the remote data from the server if the url is a remote redirection, which still happens when the image data cannot be fetched by the client browser at upload time. [1]: https://lowendbox.com/wp-content/uploads/2022/09/odoo_logo_1200.png [2]: 943944d#diff-0897c80484208197b0aff67f2b06509e864c3976de1589e3cebad2788eef008fR49 [3]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/models/ir_qweb_fields.py#L473 [4]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/controllers/main.py#L268 opw-3746245 closes #160085 Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
- Install E-commerce app - Go to Website > Shop, and open a product - Click on edit on the upper right corner. - Double click the product image to change it. A popup is shown. - In the popup, click on Add URL and place this URL [1] - Click Save. The image disappears! - The issue was introduced here [2] - As URL now starts with `/web/image/` which will be later used here [3] - The condition to enter this line is `url_object.path.startswith('/web/image')` - `item[field]` is used which equals to `attachment[datas]` - But actually `datas` is empty as the image upload fails because of CORS - `add_url` is called [4] saving attachment without `datas` but with type URL - The commit solves the issue by fetching the remote data from the server if the url is a remote redirection, which still happens when the image data cannot be fetched by the client browser at upload time. [1]: https://lowendbox.com/wp-content/uploads/2022/09/odoo_logo_1200.png [2]: odoo@943944d#diff-0897c80484208197b0aff67f2b06509e864c3976de1589e3cebad2788eef008fR49 [3]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/models/ir_qweb_fields.py#L473 [4]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/controllers/main.py#L268 opw-3746245 closes odoo#160085 Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
- Install E-commerce app - Go to Website > Shop, and open a product - Click on edit on the upper right corner. - Double click the product image to change it. A popup is shown. - In the popup, click on Add URL and place this URL [1] - Click Save. The image disappears! - The issue was introduced here [2] - As URL now starts with `/web/image/` which will be later used here [3] - The condition to enter this line is `url_object.path.startswith('/web/image')` - `item[field]` is used which equals to `attachment[datas]` - But actually `datas` is empty as the image upload fails because of CORS - `add_url` is called [4] saving attachment without `datas` but with type URL - The commit solves the issue by fetching the remote data from the server if the url is a remote redirection, which still happens when the image data cannot be fetched by the client browser at upload time. [1]: https://lowendbox.com/wp-content/uploads/2022/09/odoo_logo_1200.png [2]: odoo@943944d#diff-0897c80484208197b0aff67f2b06509e864c3976de1589e3cebad2788eef008fR49 [3]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/models/ir_qweb_fields.py#L473 [4]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/controllers/main.py#L268 opw-3746245 closes odoo#160085 Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Steps to reproduce:
Investigation:
/web/image/
which will be later used here 3url_object.path.startswith('/web/image')
item[field]
is used which equals toattachment[datas]
datas
is empty as the image upload fails because of CORSadd_url
is called 4 saving attachment withoutdatas
but with type URLFix
opw-3746245