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

org snippet caused 500 internal server error #17139

Closed
Iced-Sun opened this issue Sep 24, 2021 · 3 comments · Fixed by #17140
Closed

org snippet caused 500 internal server error #17139

Iced-Sun opened this issue Sep 24, 2021 · 3 comments · Fixed by #17140
Labels
Milestone

Comments

@Iced-Sun
Copy link

Gitea Version

1.15.2

Git Version

No response

Operating System

No response

How are you running Gitea?

Helm chart.

Database

No response

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Description

A source block with http language modifier in org-mode file causes render failure with 500 internal server error for gitea-1.15.2. A demo is located at https://try.gitea.io/Iced-Sun/org/src/branch/master/test.org.

#+begin_src http
POST https://httpbin.org/post
Content-Type: application/json

{
  "foo": "bar"
}
#+end_src

It used to work on gitea-1.14.6 and before.

Screenshots

No response

@zeripath
Copy link
Contributor

Thank you for providing a test case, however the logs would have been helpful too.

@Iced-Sun
Copy link
Author

Here is the relevant log:

2021/09/24 06:55:23 ...ers/web/repo/view.go:522:renderFile() [E] Render: orgmode.Render failed: could not write output: runtime error: index out of range [0] with length 0

@zeripath
Copy link
Contributor

OK looks like there is a panic:

			if _, err := w.WriteString(highlight.Code(lexer.Config().Filenames[0], source)); err != nil {
				return ""
			}

likely the lexer.Config().Filenames is empty.

zeripath added a commit to zeripath/gitea that referenced this issue Sep 24, 2021
When rendering source in org mode there is a mistake in the highlight code that
causes a panic.

This PR fixes this.

Fix go-gitea#17139

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit to zeripath/gitea that referenced this issue Sep 24, 2021
Backport go-gitea#17140

When rendering source in org mode there is a mistake in the highlight code that
causes a panic.

This PR fixes this.

Fix go-gitea#17139

Signed-off-by: Andrew Thornton <[email protected]>
@lunny lunny added the type/bug label Sep 24, 2021
@lunny lunny added this to the 1.15.4 milestone Sep 24, 2021
zeripath added a commit that referenced this issue Sep 24, 2021
When rendering source in org mode there is a mistake in the highlight code that
causes a panic.

This PR fixes this.

Fix #17139

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit that referenced this issue Sep 24, 2021
Backport #17140

When rendering source in org mode there is a mistake in the highlight code that
causes a panic.

This PR fixes this.

Fix #17139

Signed-off-by: Andrew Thornton <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants