Skip to content
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

It's not possible to insert an image in an event's description using an external url #6255

Open
lecabori opened this issue Mar 27, 2024 · 14 comments
Labels

Comments

@lecabori
Copy link

lecabori commented Mar 27, 2024

Hi all, @OmeGak ,
In the new 3.3 version of Indico, the CKEditorWidget has been replaced with TinyMCEWidget.
I noticed that in this new TinyMCEWidget widget, the constructor by default sets absolute_urls = False.
In an Event's description field it is now not possible to set an absolute path to images attached in the description: If I do, it will get converted to an internal url.

To Reproduce
Steps to reproduce the behavior:

  1. Go to an Event
  2. Click on Settings
  3. Edit the section for "Title, Description, Short URL"
  4. In the editor, click the "Insert/Edit image" widget icon
  5. Enter an absolute path to an image (e.g from the Customisation -> Images menu, get the link from an existing image)
  6. Then check the Source code and you'll see that the image src attribute has been changed to an internal path

Expected behavior
We would expect that the image source remains as an external url

Screenshots
image
image

Additional context
I see that the TinyMCEWidget constructor by default sets absolute_urls = False
See src/indico/web/forms/widgets.py

@lecabori lecabori added the bug label Mar 27, 2024
@lecabori lecabori changed the title It's not possible to insert and image in an event's description using an external url It's not possible to insert an image in an event's description using an external url Mar 27, 2024
@ThiefMaster
Copy link
Member

ThiefMaster commented Mar 27, 2024

Are you sure this happens in the latest version from Git (not sure which version is installed on your instance)?

I'm asking because in #6170 I fixed a problem that converted truly absolute URL to relative ones - it was mainly an issue in emails (where you should never have relative URLs for obvious reasons), but possibly it's the same thing you're encountering here.

  relative_urls: false, // kind of misleading: this just ensures domain-relative URLs
  remove_script_host: !forceAbsoluteURLs, // this ensures fully absolute (`https://....`) URLs

Feel free to test it on https://sandbox.getindico.io :)

@ThiefMaster
Copy link
Member

In any case, if you are on the latest version, and you create an absolute URL that points to the same host where Indico is running: The behavior is intentional. Absolute URLs pointing to the current instance would break if the instance ever changes (sub)domains. So keeping those links relatives makes more sense.

@lecabori
Copy link
Author

I pulled the latest version today but can't check that the issue has been fixed since I am running into errors.
However I checked the code and the constructor is the same for the TinyMCEWidget
Here is my version and pulls
image

@lecabori
Copy link
Author

In 3.2.9 it was possible to attach images using external URLs
In our particular case it's important t do so, since we update other sites from Indico and these images won't get displayed

@ThiefMaster
Copy link
Member

What error are you getting? Could it be related to being on an older Python version (3.3 requires 3.12.2)?

External URLs from other hosts than the Indico host should work fine and not be changed.

@ThiefMaster
Copy link
Member

I just tested on my instance and the current behavior is that:

  • URLs pointing to the same host as the Indico instance are always made relative
  • URLs pointing to any other host always remain absolute

@lecabori
Copy link
Author

Well I did upgrade the python version , deleted my existing env and then recreated it to use the newest version.
I then got errors about "No Indico config found. Point the INDICO_CONFIG env var to your config file or move/symlink ...", even though my indico.conf file was still in the right place.
So I simple deleted the whole src folder and reinstalled everything.
All is good, except for the fact that one of my plugins uses a package that has not been updated to use python 3.12.2, so I am stuck there until that is fixed

@lecabori
Copy link
Author

I just tested on my instance and the current behavior is that:

  • URLs pointing to the same host as the Indico instance are always made relative
  • URLs pointing to any other host always remain absolute

Yes, but it's different from the behaviour from Indico 3.2.9 where URLs from the same Indico instanced remained as absolute paths if so entered.
In our case we need it to remain absolute so that when we update our other sites with the content from Indico, the images can be correctly rendered

@ThiefMaster
Copy link
Member

The INDICO_CONFIG error should have been fixed with this commit:

* 7014cbe8ed - (upstream/master, master) Fix editable package detection (4 hours ago) <Adrian Moennich>

(it happened when installing indico in a new virtualenv without setuptools)

@lecabori
Copy link
Author

The INDICO_CONFIG error should have been fixed with this commit:

* 7014cbe8ed - (upstream/master, master) Fix editable package detection (4 hours ago) <Adrian Moennich>

(it happened when installing indico in a new virtualenv without setuptools)

Hmm, my pull included that update but I still got the error....

@ThiefMaster
Copy link
Member

Ugh. Annoying. I guess I'll have to debug this more tomorrow...

@lecabori
Copy link
Author

Ok, for now I simply deleted src and reinstalled

@ThiefMaster
Copy link
Member

ThiefMaster commented Mar 27, 2024

In our case we need it to remain absolute so that when we update our other sites with the content from Indico, the images can be correctly rendered

I don't think TinyMCE supports this, unless we force all links to become absolute which we don't want since it's not very portable...

BUT: I think the solution for you is simply that your scripts which extract content from Indico should convert links to absolute. This is actually what I do in a custom script that exposes stuff from the Indico API to an external app which needs absolute URLs.

We could possibly consider generating absolute links in any APIs that are meant to be consumed from outside Indico...

@lecabori
Copy link
Author

lecabori commented Mar 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants