mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
External markup renderer doesn't show any embedded images #1294
Closed
opened 2025-11-02 03:55:47 -06:00 by GiteaMirror
·
23 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.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-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#1294
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kzfm on GitHub (Nov 29, 2017).
[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
@lunny commented on GitHub (Nov 29, 2017):
Any repository example on github?
@kzfm commented on GitHub (Nov 29, 2017):
I created a repo.
@lunny commented on GitHub (Nov 29, 2017):
Some tags maybe has been removed for safety.
@lunny commented on GitHub (Dec 2, 2017):
This is because the render generated
<html>tag but gitea will ignore that and sub tags.@memetb commented on GitHub (Jan 1, 2018):
I'm not clear why there's a need to use
jupyterat all.gogsis able to preview these files just fine without having to re-render them (which can be unsafe and time costly). Is there a reason why this feature was lost?@ivoszz commented on GitHub (Apr 23, 2018):
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.
@lunny commented on GitHub (Apr 29, 2018):
@ivoszz your issue is different from this one, maybe you could fire another one.
@pavilo commented on GitHub (Nov 23, 2018):
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?
To make something meaningful our of the external markup renderer one may have to use things like scoped CSS, images (both data URI and links to raw project resources) and unfortunately sometimes also javascript (e.g. MathJax, jupyter widgets etc). In extreme cases an iframe may be required too.
This configuration mostly works for a jupyter notebook with python code and embedded images:
@bekker commented on GitHub (Nov 28, 2018):
I'm not sure it's exactly the same issue, but
<img>tags with relative image path in.mdfiles needs to be switched to 'raw' path, like github and gogs handle them.@programagor commented on GitHub (Feb 22, 2019):
@pavilo Does that mean that I'd need to recompile Gitea with the modified
sanitizer.goin order to display Jupyter notebooks? Is it possible to expose these settings inapp.iniinstead?@Tdarnell commented on GitHub (Feb 22, 2019):
I have also run into this issue and would second disabling certain sanitiser settings in the markdown.jupyter section of app.ini
@pavilo commented on GitHub (Feb 23, 2019):
@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.
@stale[bot] commented on GitHub (Apr 24, 2019):
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.
@worthy7 commented on GitHub (Apr 25, 2019):
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:
http://localhost:3000/Me/MyProject/media/branch/master/doc/markdown-images/install.pngWhich gives a 404.
As you can see, the problem is that it is ignoring subfolders
doc/markdown-images/@worthy7 commented on GitHub (Apr 25, 2019):
Ok, the problem it is needed to be like this:
@eapetitfils commented on GitHub (Apr 25, 2019):
@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?
@worthy7 commented on GitHub (Apr 25, 2019):
@eapetitfils Ah sorry, didn't mean to issue hijack.
I'm not sure what bug you are referring to in your second paragraph there, mine, or this issue3025
@eapetitfils commented on GitHub (Apr 25, 2019):
@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.
@limenleap commented on GitHub (Jun 10, 2019):
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:
@echo ^<div id='splview-%1' ^>Click here to view this file^</div^>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:
I had ensured that the custom/conf/app.ini file was configured to execute that batch file, as the external renderer, for the given filetype
Hope this works out. Fingers crossed
@stale[bot] commented on GitHub (Aug 9, 2019):
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.
@entron commented on GitHub (Jul 28, 2020):
Same problem here. Any updates on this issue?
@mrsdizzie commented on GitHub (Sep 7, 2020):
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.
@entron commented on GitHub (Sep 20, 2020):
@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.