maybe a bug report: FOOTER_ORGANIZATION_LOGO cannot be an absolute URL

32 views
Skip to first unread message

Mahyar Damavand

unread,
Feb 23, 2019, 9:39:34 AM2/23/19
to Open edX operations
hello edx team, 
I found that it is not possible to give an absolute URL to the FOOTER_ORGANIZATION_LOGO in settings.
to test this you can easily run an edxapp shell and execute the following commands:

>>> from django.conf import settings
>>> settings.FOOTER_ORGANIZATION_IMAGE = u'http://cdn.example.com/static/image.png'
>>> from branding.api import get_footer
>>> get_footer()
Traceback (most recent call last):
    File "<console>", line 1, in <module>
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/branding/api.py", line 100, in get_footer
        "logo_image": _footer_logo_img(is_secure),
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/branding/api.py", line 360, in _footer_logo_img
        return _absolute_url_staticfile(is_secure, logo_name)
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/branding/api.py", line 407, in _absolute_url_staticfile
        url_path = staticfiles_storage.url(name)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 162, in url
        return self._url(self.stored_name, name, force)
    File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/theming/storage.py", line 179, in _url
        processed_asset_name = self._processed_asset_name(name)
    File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/theming/storage.py", line 164, in _processed_asset_name
        if not self.exists(clean_name):
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/files/storage.py", line 392, in exists
        return os.path.exists(self.path(name))
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 53, in path
        return super(StaticFilesStorage, self).path(name)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/files/storage.py", line 405, in path
        return safe_join(self.location, name)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/_os.py", line 78, in safe_join
        'component ({})'.format(final_path, base_path))
SuspiciousFileOperation: The joined path (/static/image.png) is located outside of the base path component (/edx/var/edxapp/staticfiles)
>>> _

unfortunately the staticfiles_storage.url is patched out in the unit tests and unable to show this bug.

I also set this value manually in my lms.env.json and faced with error in log files.
If this is because of my fault pleas let me know 
thank you

Mahyar Damavand

unread,
Feb 28, 2019, 8:51:33 PM2/28/19
to Open edX operations
Hi
I would be grateful if somebody check and confirm this.
Simply set the FOOTER_ORGANIZATION_LOGO in lms.env.py to http://cdn.example.com/static/image.png and see if you got an Internal Server Error in your site homepage.

Regards
Mahyard

David Ormsbee

unread,
Mar 4, 2019, 9:14:53 AM3/4/19
to opene...@googlegroups.com
Hi Mahyard,

Glancing at the code, I agree that this is an issue with edx-platform. The code assumes the logo comes from static files storage that Django controls, and can't be any arbitrary URL. I'm not sure whether the fact that we don't support this use case is a bug or a lack of a feature, but at the least we should be giving a more helpful error message.

You can create a ticket for it at: https://openedx.atlassian.net/projects/CRI

If you're interested in working on a fix, please submit a PR to edx-platform and tag me (@ormsbee) on it. Otherwise, I really can't say when it will be fixed.

Thank you.

Dave

--
You received this message because you are subscribed to the Google Groups "Open edX operations" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openedx-ops/CABCzmJJZo-wFgMnPQ_BQwRGvn%2BqUGccgfOhm1Tx3CWvgBo8XLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Mahyar Damavand

unread,
Mar 5, 2019, 3:50:12 AM3/5/19
to opene...@googlegroups.com
Hello Mr. David Ormsbee,
Actually I'm not sure if I saw somewhere in edx documents about possibility of using an absolute URL for the footer logo assignment.
but I assumed that it should be possible because of this test case:
and also this docstring:

btw it will be my honor to contribute to edx-platform again.
give me some days to mange it and create a PR. also tell me if you have any idea about this let me know.

Thank you for the answer 
Mahyard

Reply all
Reply to author
Forward
0 new messages