loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix inline file preview for files with encoded URL, fix #5069 (#6525)

### Screenshot
#### Before
See #5069.
#### After
![image](/attachments/d57c2ff8-d29e-41b8-9280-c884ac43f12e)
### Tests

- I added test coverage for Go changes...
- [x] in their respective `*_test.go` for unit tests.
- [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
- [ ] in `web_src/js/*.test.js` if it can be unit tested.
- [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).
- Manual testing: see https://codeberg.org/forgejo/forgejo/pulls/6525#issuecomment-2578814. Thanks @earl-warren.

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [ ] I do not want this change to show in the release notes.
- [ ] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6525
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: Robert Wolff <mahlzahn@posteo.de>
Co-committed-by: Robert Wolff <mahlzahn@posteo.de>

authored by

Robert Wolff
Robert Wolff
and committed by
Earl Warren
c0a2108c 1698210e

+38 -1
+5
modules/markup/file_preview.go
··· 8 8 "bytes" 9 9 "html/template" 10 10 "io" 11 + "net/url" 11 12 "regexp" 12 13 "slices" 13 14 "strconv" ··· 82 83 filePath = strings.TrimSuffix(filePath, "?display=source") 83 84 } else if Type(filePath) != "" { 84 85 urlFullSource = node.Data[m[0]:m[6]] + filePath + "?display=source#" + node.Data[m[8]:m[1]] 86 + } 87 + filePath, err := url.QueryUnescape(filePath) 88 + if err != nil { 89 + return nil 85 90 } 86 91 hash := node.Data[m[8]:m[9]] 87 92
+31
modules/markup/html_test.go
··· 1129 1129 localMetas, 1130 1130 ) 1131 1131 }) 1132 + 1133 + commitFileURL = util.URLJoin(markup.TestRepoURL, "src", "commit", "eeb243c3395e1921c5d90e73bd739827251fc99d", "path", "to", "file%20%23.txt") 1134 + 1135 + t.Run("file with strange characters in name", func(t *testing.T) { 1136 + testRender( 1137 + commitFileURL+"#L1", 1138 + `<p></p>`+ 1139 + `<div class="file-preview-box">`+ 1140 + `<div class="header">`+ 1141 + `<div>`+ 1142 + `<a href="http://localhost:3000/gogits/gogs/src/commit/eeb243c3395e1921c5d90e73bd739827251fc99d/path/to/file%20%23.txt#L1" class="muted" rel="nofollow">path/to/file #.txt</a>`+ 1143 + `</div>`+ 1144 + `<span class="text small grey">`+ 1145 + `Line 1 in <a href="http://localhost:3000/gogits/gogs/src/commit/eeb243c3395e1921c5d90e73bd739827251fc99d" class="text black" rel="nofollow">eeb243c</a>`+ 1146 + `</span>`+ 1147 + `</div>`+ 1148 + `<div class="ui table">`+ 1149 + `<table class="file-preview">`+ 1150 + `<tbody>`+ 1151 + `<tr>`+ 1152 + `<td class="lines-num"><span data-line-number="1"></span></td>`+ 1153 + `<td class="lines-code chroma"><code class="code-inner">A`+"\n"+`</code></td>`+ 1154 + `</tr>`+ 1155 + `</tbody>`+ 1156 + `</table>`+ 1157 + `</div>`+ 1158 + `</div>`+ 1159 + `<p></p>`, 1160 + localMetas, 1161 + ) 1162 + }) 1132 1163 }
modules/markup/tests/repo/repo1_filepreview/objects/18/9739e1c2a6cdb8ee094ba1ef8a2e40cf65b2ec

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/2a/4032b49cff56d6d4921133e087d9dc0341a2c5

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/2d/2f8eaa17b17359ee1c73222065575d50d9a157

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/2f/b9577a8e940a0a84a789cdd4a45d0f172e3fdd

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/2f/f8eb63aad050c3f20e9cb27090ab7378267ab2

This is a binary file and will not be displayed.

+1
modules/markup/tests/repo/repo1_filepreview/objects/3e/2a4f1b9a15ffa15ea7ffdc06acd302442b3eca
··· 1 + x��AN�0EY��GB;a U=D9�=�&����r}�7��������ҌB�^����yY8�:A�� X}�R�Xk�s�"�;u�F��9x��� �EdВ%�~**Z�3\��v��9Й>n�8�fxk�=�[9K�%L>����{��7�s�;a�v�4�hXO�H�ԓ�Ն��`K�
modules/markup/tests/repo/repo1_filepreview/objects/8a/3b1881b5c4e7dc2be7ee1c0f37f93ffbb5ff77

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/95/31b649823095acf5d79ab9e4f8b8d86046352f

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/ac/769ab4baa91060a4c2f828f53e6c3cc2f708f8

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/c5/3110b1957cefc56c4b2d879476ddbe905980bf

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/e7/99b34ea867a0364d0df33f382562db9ff39084

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/ee/b243c3395e1921c5d90e73bd739827251fc99d

This is a binary file and will not be displayed.

modules/markup/tests/repo/repo1_filepreview/objects/f7/0f10e4db19068f79bc43844b49f3eece45c4e8

This is a binary file and will not be displayed.

+1 -1
modules/markup/tests/repo/repo1_filepreview/refs/heads/master
··· 1 - c9913120ed2c1e27c1d7752ecdb7a504dc7cf6be 1 + eeb243c3395e1921c5d90e73bd739827251fc99d