forked from gohugoio/hugo
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes gohugoio#12626 Closes gohugoio#7499 Closes gohugoio#9978 Closes gohugoio#12879 Closes gohugoio#13113 Fixes gohugoio#13116
- Loading branch information
Showing
63 changed files
with
4,586 additions
and
971 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2024 The Hugo Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build !windows | ||
|
||
package paths | ||
|
||
import ( | ||
"errors" | ||
"path/filepath" | ||
) | ||
|
||
// From https://github.com/golang/go/blob/6c25cf1c5fc063cc9ea27aa850ef0c4345f3a5b4/src/cmd/go/internal/web/url_other.go#L14 | ||
func convertFileURLPath(host, path string) (string, error) { | ||
switch host { | ||
case "", "localhost": | ||
default: | ||
return "", errors.New("file URL specifies non-local host") | ||
} | ||
return filepath.FromSlash(path), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2024 The Hugo Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package paths | ||
|
||
import ( | ||
"errors" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// From https://github.com/golang/go/blob/6c25cf1c5fc063cc9ea27aa850ef0c4345f3a5b4/src/cmd/go/internal/web/url_windows.go#L13 | ||
func convertFileURLPath(host, path string) (string, error) { | ||
if len(path) == 0 || path[0] != '/' { | ||
return "", errors.New("file URL path must start with /") | ||
} | ||
|
||
path = filepath.FromSlash(path) | ||
|
||
// We interpret Windows file URLs per the description in | ||
// https://blogs.msdn.microsoft.com/ie/2006/12/06/file-uris-in-windows/. | ||
|
||
// The host part of a file URL (if any) is the UNC volume name, | ||
// but RFC 8089 reserves the authority "localhost" for the local machine. | ||
if host != "" && host != "localhost" { | ||
// A common "legacy" format omits the leading slash before a drive letter, | ||
// encoding the drive letter as the host instead of part of the path. | ||
// (See https://blogs.msdn.microsoft.com/freeassociations/2005/05/19/the-bizarre-and-unhappy-story-of-file-urls/.) | ||
// We do not support that format, but we should at least emit a more | ||
// helpful error message for it. | ||
if filepath.VolumeName(host) != "" { | ||
return "", errors.New("file URL encodes volume in host field: too few slashes?") | ||
} | ||
return `\\` + host + path, nil | ||
} | ||
|
||
// If host is empty, path must contain an initial slash followed by a | ||
// drive letter and path. Remove the slash and verify that the path is valid. | ||
if vol := filepath.VolumeName(path[1:]); vol == "" || strings.HasPrefix(vol, `\\`) { | ||
return "", errors.New("file URL missing drive letter") | ||
} | ||
return path[1:], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.