File tree Expand file tree Collapse file tree 4 files changed +22
-7
lines changed
templates/repo/issue/view_content Expand file tree Collapse file tree 4 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,16 @@ func DetectContentType(data []byte) SniffedType {
106
106
}
107
107
}
108
108
109
+ if strings .HasPrefix (ct , "audio/" ) && bytes .HasPrefix (data , []byte ("ID3" )) {
110
+ // The MP3 detection is quite inaccurate, any content with "ID3" prefix will result in "audio/mpeg".
111
+ // So remove the "ID3" prefix and detect again, if result is text, then it must be text content.
112
+ // This works especially because audio files contain many unprintable/invalid characters like `0x00`
113
+ ct2 := http .DetectContentType (data [3 :])
114
+ if strings .HasPrefix (ct2 , "text/" ) {
115
+ ct = ct2
116
+ }
117
+ }
118
+
109
119
return SniffedType {ct }
110
120
}
111
121
Original file line number Diff line number Diff line change @@ -109,6 +109,10 @@ func TestIsAudio(t *testing.T) {
109
109
mp3 , _ := base64 .StdEncoding .DecodeString ("SUQzBAAAAAABAFRYWFgAAAASAAADbWFqb3JfYnJhbmQAbXA0MgBUWFhYAAAAEQAAA21pbm9yX3Zl" )
110
110
assert .True (t , DetectContentType (mp3 ).IsAudio ())
111
111
assert .False (t , DetectContentType ([]byte ("plain text" )).IsAudio ())
112
+
113
+ assert .True (t , DetectContentType ([]byte ("ID3Toy\000 " )).IsAudio ())
114
+ assert .True (t , DetectContentType ([]byte ("ID3Toy\n ====\t * hi 🌞, ..." )).IsText ()) // test ID3 tag for plain text
115
+ assert .True (t , DetectContentType ([]byte ("ID3Toy\n ====\t * hi 🌞, ..." + "🌛" [0 :2 ])).IsText ()) // test ID3 tag with incomplete UTF8 char
112
116
}
113
117
114
118
func TestDetectContentTypeFromReader (t * testing.T ) {
Original file line number Diff line number Diff line change 10
10
{{else}}
11
11
{{$referenceUrl = Printf "%s/files#%s" .ctxData.Issue.Link .item.HashTag}}
12
12
{{end}}
13
- <a class="item context" data-clipboard-text-type="url" data-clipboard-text="{{AppSubUrl}}{{$referenceUrl}}">{{.ctxData.locale.Tr "repo.issues.context.copy_link"}}</a >
14
- <a class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.HashTag}}-raw">{{.ctxData.locale.Tr "repo.issues.context.quote_reply"}}</a >
13
+ <div class="item context js-aria-clickable " data-clipboard-text-type="url" data-clipboard-text="{{AppSubUrl}}{{$referenceUrl}}">{{.ctxData.locale.Tr "repo.issues.context.copy_link"}}</div >
14
+ <div class="item context js-aria-clickable quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.HashTag}}-raw">{{.ctxData.locale.Tr "repo.issues.context.quote_reply"}}</div >
15
15
{{if not .ctxData.UnitIssuesGlobalDisabled}}
16
- <a class="item context reference-issue" data-target="{{.item.HashTag}}-raw" data-modal="#reference-issue-modal" data-poster="{{.item.Poster.GetDisplayName}}" data-poster-username="{{.item.Poster.Name}}" data-reference="{{$referenceUrl}}">{{.ctxData.locale.Tr "repo.issues.context.reference_issue"}}</a >
16
+ <div class="item context js-aria-clickable reference-issue" data-target="{{.item.HashTag}}-raw" data-modal="#reference-issue-modal" data-poster="{{.item.Poster.GetDisplayName}}" data-poster-username="{{.item.Poster.Name}}" data-reference="{{$referenceUrl}}">{{.ctxData.locale.Tr "repo.issues.context.reference_issue"}}</div >
17
17
{{end}}
18
18
{{if or .ctxData.Permission.IsAdmin .IsCommentPoster .ctxData.HasIssuesOrPullsWritePermission}}
19
19
<div class="divider"></div>
20
- <a class="item context edit-content">{{.ctxData.locale.Tr "repo.issues.context.edit"}}</a >
20
+ <div class="item context js-aria-clickable edit-content">{{.ctxData.locale.Tr "repo.issues.context.edit"}}</div >
21
21
{{if .delete}}
22
- <a class="item context delete-comment" data-comment-id={{.item.HashTag}} data-url="{{.ctxData.RepoLink}}/comments/{{.item.ID}}/delete" data-locale="{{.ctxData.locale.Tr "repo.issues.delete_comment_confirm"}}">{{.ctxData.locale.Tr "repo.issues.context.delete"}}</a >
22
+ <div class="item context js-aria-clickable delete-comment" data-comment-id={{.item.HashTag}} data-url="{{.ctxData.RepoLink}}/comments/{{.item.ID}}/delete" data-locale="{{.ctxData.locale.Tr "repo.issues.delete_comment_confirm"}}">{{.ctxData.locale.Tr "repo.issues.context.delete"}}</div >
23
23
{{end}}
24
24
{{end}}
25
25
</div>
Original file line number Diff line number Diff line change @@ -84,8 +84,9 @@ function attachOneDropdownAria($dropdown) {
84
84
if ( e . key === 'Enter' ) {
85
85
let $item = $dropdown . dropdown ( 'get item' , $dropdown . dropdown ( 'get value' ) ) ;
86
86
if ( ! $item ) $item = $menu . find ( '> .item.selected' ) ; // when dropdown filters items by input, there is no "value", so query the "selected" item
87
- // if the selected item is clickable, then trigger the click event. in the future there could be a special CSS class for it.
88
- if ( $item && $item . is ( 'a' ) ) $item [ 0 ] . click ( ) ;
87
+ // if the selected item is clickable, then trigger the click event.
88
+ // we can not click any item without check, because Fomantic code might also handle the Enter event. that would result in double click.
89
+ if ( $item && ( $item . is ( 'a' ) || $item . is ( '.js-aria-clickable' ) ) ) $item [ 0 ] . click ( ) ;
89
90
}
90
91
} ) ;
91
92
You can’t perform that action at this time.
0 commit comments