mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 10:37:24 -04:00 
			
		
		
		
	Change CASE_SENSITIVE_PATH default to false
A default of true is risky when protecting assets by matching base path. It's not obvious that protecting /foo/ will allow /Foo/ through, and if accessing static files on a case-insensitive file system... that's no good. So the default is now to be case-INsensitive when matching paths.
This commit is contained in:
		
							parent
							
								
									cccfe3b4ef
								
							
						
					
					
						commit
						b0d9c058cc
					
				| @ -158,7 +158,7 @@ func SetLastModifiedHeader(w http.ResponseWriter, modTime time.Time) { | |||||||
| 
 | 
 | ||||||
| // CaseSensitivePath determines if paths should be case sensitive. | // CaseSensitivePath determines if paths should be case sensitive. | ||||||
| // This is configurable via CASE_SENSITIVE_PATH environment variable. | // This is configurable via CASE_SENSITIVE_PATH environment variable. | ||||||
| var CaseSensitivePath = true | var CaseSensitivePath = false | ||||||
| 
 | 
 | ||||||
| const caseSensitivePathEnv = "CASE_SENSITIVE_PATH" | const caseSensitivePathEnv = "CASE_SENSITIVE_PATH" | ||||||
| 
 | 
 | ||||||
| @ -167,10 +167,10 @@ const caseSensitivePathEnv = "CASE_SENSITIVE_PATH" | |||||||
| // This could have been in init, but init cannot be called from tests. | // This could have been in init, but init cannot be called from tests. | ||||||
| func initCaseSettings() { | func initCaseSettings() { | ||||||
| 	switch os.Getenv(caseSensitivePathEnv) { | 	switch os.Getenv(caseSensitivePathEnv) { | ||||||
| 	case "0", "false": | 	case "1", "true": | ||||||
| 		CaseSensitivePath = false |  | ||||||
| 	default: |  | ||||||
| 		CaseSensitivePath = true | 		CaseSensitivePath = true | ||||||
|  | 	default: | ||||||
|  | 		CaseSensitivePath = false | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -59,7 +59,7 @@ func TestPathCaseSensitiveEnv(t *testing.T) { | |||||||
| 		{"0", false}, | 		{"0", false}, | ||||||
| 		{"false", false}, | 		{"false", false}, | ||||||
| 		{"true", true}, | 		{"true", true}, | ||||||
| 		{"", true}, | 		{"", false}, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	for i, test := range tests { | 	for i, test := range tests { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user