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

diff view leaks some html code #13177

Closed
2 of 7 tasks
zig opened this issue Oct 16, 2020 · 5 comments · Fixed by #13191
Closed
2 of 7 tasks

diff view leaks some html code #13177

zig opened this issue Oct 16, 2020 · 5 comments · Fixed by #13191
Labels

Comments

@zig
Copy link

zig commented Oct 16, 2020

Description

Diff view sometimes show additional html tag that should not be visible

Screenshots

image

But it should be :

-    print "// ", sys.argv
+    print("// ", sys.argv)

Note however that the extra tag is not visible in the file view :
image

@zeripath
Copy link
Contributor

Heya @mrsdizzie are you able to take a look?

@techknowlogick
Copy link
Member

@zig as you are running a development version, could you upgrade to the latest commit? There have been some changes to the above (specifically diff handling & chroma)

@mrsdizzie
Copy link
Member

This was a bug that was fixed a few months ago during syntax highlighting transition and shouldn't be present anymore. Can you link to a current example of this? Or put up an example on try.gitea.io. If it isn't private you could just push the repo and it would retain the commit history that should produce the diff.

I tried to reproduce with the small example given but it looks ok to me:

https://try.gitea.io/mrsdizzie/testme/commit/3d06f1f836fc248bbba9be7a8c18d019559e7ccb

But it might depend on other information so an example to see would be best. Thanks!

@zig
Copy link
Author

zig commented Oct 17, 2020

@mrsdizzie thanks for looking into this, in your test you added a space between print and the (, without a space, the bug occurs :

https://try.gitea.io/zigg/testme/commit/9bd6915f409b3ae13dd284a716212059129c8dfe

@mrsdizzie
Copy link
Member

@zig thanks, will look into

mrsdizzie added a commit to mrsdizzie/gitea that referenced this issue Oct 17, 2020
Was missing an optional whitespace check in regex. Also noticed a rare case where diff.Type == Equal would be empty and thus get a newline attached. Fixed that too.

Fixes go-gitea#13177
@lunny lunny added the type/bug label Oct 18, 2020
techknowlogick pushed a commit that referenced this issue Oct 18, 2020
* Fix error in diff html rendering

Was missing an optional whitespace check in regex. Also noticed a rare case where diff.Type == Equal would be empty and thus get a newline attached. Fixed that too.

Fixes #13177

* Update services/gitdiff/gitdiff.go

Co-authored-by: zeripath <[email protected]>

* Update gitdiff_test.go

* fmt

Co-authored-by: zeripath <[email protected]>
mrsdizzie added a commit to mrsdizzie/gitea that referenced this issue Oct 21, 2020
* Fix error in diff html rendering

Was missing an optional whitespace check in regex. Also noticed a rare case where diff.Type == Equal would be empty and thus get a newline attached. Fixed that too.

Fixes go-gitea#13177

* Update services/gitdiff/gitdiff.go

Co-authored-by: zeripath <[email protected]>

* Update gitdiff_test.go

* fmt

Co-authored-by: zeripath <[email protected]>
techknowlogick pushed a commit that referenced this issue Oct 22, 2020
* Fix error in diff html rendering (#13191)

* Fix error in diff html rendering

Was missing an optional whitespace check in regex. Also noticed a rare case where diff.Type == Equal would be empty and thus get a newline attached. Fixed that too.

Fixes #13177

* Update services/gitdiff/gitdiff.go

Co-authored-by: zeripath <[email protected]>

* Update gitdiff_test.go

* fmt

Co-authored-by: zeripath <[email protected]>

* Add better error checking for inline html diff code (#13239)

* Add better error checking for inline html diff code

A better fix for #13191 which cleans up this code a bit and adds basic checking which should avoid writing broken HTML in future situations.

* Update gitdiff_test.go

* better regex

Co-authored-by: zeripath <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
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.

5 participants