mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Vendor Update (#14496)
* update code.gitea.io/sdk/gitea v0.13.1 -> v0.13.2 * update github.com/go-swagger/go-swagger v0.25.0 -> v0.26.0 * update github.com/google/uuid v1.1.2 -> v1.2.0 * update github.com/klauspost/compress v1.11.3 -> v1.11.7 * update github.com/lib/pq 083382b7e6fc -> v1.9.0 * update github.com/markbates/goth v1.65.0 -> v1.66.1 * update github.com/mattn/go-sqlite3 v1.14.4 -> v1.14.6 * update github.com/mgechev/revive 246eac737dc7 -> v1.0.3 * update github.com/minio/minio-go/v7 v7.0.6 -> v7.0.7 * update github.com/niklasfasching/go-org v1.3.2 -> v1.4.0 * update github.com/olivere/elastic/v7 v7.0.21 -> v7.0.22 * update github.com/pquerna/otp v1.2.0 -> v1.3.0 * update github.com/xanzy/go-gitlab v0.39.0 -> v0.42.0 * update github.com/yuin/goldmark v1.2.1 -> v1.3.1
This commit is contained in:
		
							
								
								
									
										41
									
								
								vendor/github.com/go-openapi/spec/normalizer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								vendor/github.com/go-openapi/spec/normalizer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,9 +20,12 @@ import ( | ||||
| 	"os" | ||||
| 	"path" | ||||
| 	"path/filepath" | ||||
| 	"runtime" | ||||
| 	"strings" | ||||
| ) | ||||
|  | ||||
| const windowsOS = "windows" | ||||
|  | ||||
| // normalize absolute path for cache. | ||||
| // on Windows, drive letters should be converted to lower as scheme in net/url.URL | ||||
| func normalizeAbsPath(path string) string { | ||||
| @@ -71,27 +74,51 @@ func normalizePaths(refPath, base string) string { | ||||
| 	return baseURL.String() | ||||
| } | ||||
|  | ||||
| // isRoot is a temporary hack to discern windows file ref for ref.IsRoot(). | ||||
| // TODO: a more thorough change is needed to handle windows file refs. | ||||
| func isRoot(ref *Ref) bool { | ||||
| 	if runtime.GOOS != windowsOS { | ||||
| 		return ref.IsRoot() | ||||
| 	} | ||||
| 	return !filepath.IsAbs(ref.String()) | ||||
| } | ||||
|  | ||||
| // isAbs is a temporary hack to discern windows file ref for url IsAbs(). | ||||
| // TODO: a more thorough change is needed to handle windows file refs. | ||||
| func isAbs(u *url.URL) bool { | ||||
| 	if runtime.GOOS != windowsOS { | ||||
| 		return u.IsAbs() | ||||
| 	} | ||||
| 	if len(u.Scheme) <= 1 { | ||||
| 		// drive letter got caught as URI scheme | ||||
| 		return false | ||||
| 	} | ||||
| 	return u.IsAbs() | ||||
| } | ||||
|  | ||||
| // denormalizePaths returns to simplest notation on file $ref, | ||||
| // i.e. strips the absolute path and sets a path relative to the base path. | ||||
| // | ||||
| // This is currently used when we rewrite ref after a circular ref has been detected | ||||
| func denormalizeFileRef(ref *Ref, relativeBase, originalRelativeBase string) *Ref { | ||||
| 	debugLog("denormalizeFileRef for: %s", ref.String()) | ||||
| 	debugLog("denormalizeFileRef for: %s (relative: %s, original: %s)", ref.String(), | ||||
| 		relativeBase, originalRelativeBase) | ||||
|  | ||||
| 	if ref.String() == "" || ref.IsRoot() || ref.HasFragmentOnly { | ||||
| 	// log.Printf("denormalize: %s, IsRoot: %t,HasFragmentOnly: %t, HasFullURL: %t", ref.String(), ref.IsRoot(), ref.HasFragmentOnly, ref.HasFullURL) | ||||
| 	if ref.String() == "" || isRoot(ref) || ref.HasFragmentOnly { | ||||
| 		return ref | ||||
| 	} | ||||
| 	// strip relativeBase from URI | ||||
| 	relativeBaseURL, _ := url.Parse(relativeBase) | ||||
| 	relativeBaseURL.Fragment = "" | ||||
|  | ||||
| 	if relativeBaseURL.IsAbs() && strings.HasPrefix(ref.String(), relativeBase) { | ||||
| 	if isAbs(relativeBaseURL) && strings.HasPrefix(ref.String(), relativeBase) { | ||||
| 		// this should work for absolute URI (e.g. http://...): we have an exact match, just trim prefix | ||||
| 		r, _ := NewRef(strings.TrimPrefix(ref.String(), relativeBase)) | ||||
| 		return &r | ||||
| 	} | ||||
|  | ||||
| 	if relativeBaseURL.IsAbs() { | ||||
| 	if isAbs(relativeBaseURL) { | ||||
| 		// other absolute URL get unchanged (i.e. with a non-empty scheme) | ||||
| 		return ref | ||||
| 	} | ||||
| @@ -111,7 +138,7 @@ func denormalizeFileRef(ref *Ref, relativeBase, originalRelativeBase string) *Re | ||||
| 	//   my normalized ref points to: /mypath/item.json#/target | ||||
| 	//   expected result: item.json#/target | ||||
| 	parts := strings.Split(ref.String(), "#") | ||||
| 	relativePath, err := filepath.Rel(path.Dir(originalRelativeBaseURL.String()), parts[0]) | ||||
| 	relativePath, err := filepath.Rel(filepath.Dir(originalRelativeBaseURL.String()), parts[0]) | ||||
| 	if err != nil { | ||||
| 		// there is no common ancestor (e.g. different drives on windows) | ||||
| 		// leaves the ref unchanged | ||||
| @@ -132,8 +159,6 @@ func normalizeFileRef(ref *Ref, relativeBase string) *Ref { | ||||
| 		return &r | ||||
| 	} | ||||
|  | ||||
| 	debugLog("normalizing %s against %s", ref.String(), relativeBase) | ||||
|  | ||||
| 	s := normalizePaths(ref.String(), relativeBase) | ||||
| 	r, _ := NewRef(s) | ||||
| 	return &r | ||||
| @@ -148,5 +173,5 @@ func absPath(fname string) (string, error) { | ||||
| 		return fname, nil | ||||
| 	} | ||||
| 	wd, err := os.Getwd() | ||||
| 	return filepath.Join(wd, fname), err | ||||
| 	return normalizeAbsPath(filepath.Join(wd, fname)), err | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 6543
					6543