-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
External markup renderer doesn't show any embedded images #3025
Comments
Any repository example on github? |
I created a repo. |
Some tags maybe has been removed for safety. |
This is because the render generated |
I'm not clear why there's a need to use |
Same problem for asciidoc. The rendered path for images has the form "https://name.domain/user/repo/src/branch/master/file.png instead of correct "https://name.domain/user/repo/raw/branch/master/file.png. |
@ivoszz your issue is different from this one, maybe you could fire another one. |
It looks like the root cause for this is in the sanitizer. It removes a lot of things, such as inline (incl scoped) CSS, images with data URIs, iframes etc. Is it possible to add an external sanitization configuration per markup handler? This configuration mostly works for a jupyter notebook with python code and embedded images: sanitizer.policy.AllowImages()
sanitizer.policy.AllowDataURIImages()
sanitizer.policy.AllowLists()
sanitizer.policy.AllowTables()
sanitizer.policy.AllowAttrs("class").Globally() // may targeted at concrete elements e.g. div, span, a, h1 ...
sanitizer.policy.AllowAttrs("type", "scoped").OnElements("style") |
@pavilo Does that mean that I'd need to recompile Gitea with the modified |
I have also run into this issue and would second disabling certain sanitiser settings in the markdown.jupyter section of app.ini |
@programagor - yes, recompilation may be needed. Moreover, I only tested this config as a standalone golang executable, to make sure that the jupyter page renders as expected. The integration into gitea may require additional modifications. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions. |
Hi, This is a problem. I created images in my markdown file like this :
And on my local machine using VS, markdown preview extension it can see them fine. When uploaded to gitea, it is trying to render this: Which gives a 404. As you can see, the problem is that it is ignoring subfolders |
Ok, the problem it is needed to be like this:
|
@worthy7 Yes, that's what I thought. This bug is about images that are embedded in the HTML since images do not exist as a separate file. For markdown, this was an issue with path only. For this particular bug, the solution is trivial but imply some security questions. I could not find any credible exploit possible, but I am no security expert, are we happy if I modify it and do a pull request so that this can be discussed there instead of pushing the milestone here? |
@eapetitfils Ah sorry, didn't mean to issue hijack. |
@worthy7 no problem, at least the next person wondering why the images are not shown will see your answer. The bug (or undesired feature as a matter of fact) I am referring to is this issue3025, not the markdown one. |
I got kind of a workaround. Not a good solution, but a workaround: It looks to me that the sanitizer does not disturb a div tag with an ID. So in Windows I wrote a batch file which just echoed that div thus:
In the above statement %1 is the name of the temporary file that Gitea creates just before executing this batch file. (In Linux bash script, I think the parameter is $1 ) Now, before echoing out that statement, I of course did all the work (shhh...dont tell Gitea) and saved the converted HTML file somewhere else Then in the custom template at custom\templates\custom\footer.tmpl at the Gitea executable folder; I wrote this script block
In my case, I am over-writing just one HTML file so for each file that uses this route, the eventual batch file generated HTML would be the same file (i.e. it is overwritten) -- at least that is what I plan to do. I have reached till here -- now I need to write the code for popping up a separate window to display that batch file generated HTML .... Note: Hope this works out. Fingers crossed |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions. |
Same problem here. Any updates on this issue? |
You can now exclude classes from the sanitizer for these cases, described with example here: https://docs.gitea.io/en-us/external-renderers/#appini-file-configuration Other issue of generated image paths have been fixed previously as well. |
@mrsdizzie Thanks for the update! Could you give an example for showing embeded plots in Jupyter notebooks? I couldn't find it in the documentation. |
[x]
):Description
I added some option into my app.ini.
Now, converting from ipynb to html works, but it doesn’t show any embedded images.
my jupyter notebook example code is here.
...
Screenshots
The text was updated successfully, but these errors were encountered: