mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 14:02:25 -05:00 
			
		
		
		
	[bugfix] add stricter checks during all stages of dereferencing remote AS objects (#2639)
* add stricter checks during all stages of dereferencing remote AS objects * a comment
This commit is contained in:
		
					parent
					
						
							
								142b7ec54f
							
						
					
				
			
			
				commit
				
					
						2bafd7daf5
					
				
			
		
					 15 changed files with 345 additions and 162 deletions
				
			
		
							
								
								
									
										75
									
								
								internal/api/util/mime_test.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								internal/api/util/mime_test.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,75 @@ | |||
| package util_test | ||||
| 
 | ||||
| import ( | ||||
| 	"testing" | ||||
| 
 | ||||
| 	"github.com/superseriousbusiness/gotosocial/internal/api/util" | ||||
| ) | ||||
| 
 | ||||
| func TestIsASContentType(t *testing.T) { | ||||
| 	for _, test := range []struct { | ||||
| 		Input  string | ||||
| 		Expect bool | ||||
| 	}{ | ||||
| 		{ | ||||
| 			Input:  "application/activity+json", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/activity+json; charset=utf-8", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/activity+json;charset=utf-8", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/activity+json ;charset=utf-8", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/activity+json ; charset=utf-8", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json;profile=https://www.w3.org/ns/activitystreams", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json;profile=\"https://www.w3.org/ns/activitystreams\"", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json ;profile=https://www.w3.org/ns/activitystreams", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json ;profile=\"https://www.w3.org/ns/activitystreams\"", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json ; profile=https://www.w3.org/ns/activitystreams", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json ; profile=\"https://www.w3.org/ns/activitystreams\"", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json; profile=https://www.w3.org/ns/activitystreams", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", | ||||
| 			Expect: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Input:  "application/ld+json", | ||||
| 			Expect: false, | ||||
| 		}, | ||||
| 	} { | ||||
| 		if util.ASContentType(test.Input) != test.Expect { | ||||
| 			t.Errorf("did not get expected result %v for input: %s", test.Expect, test.Input) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue