Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace filepath.Match with path.Match#452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletionsaccept.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ import (
"net/http"
"net/textproto"
"net/url"
"path/filepath"
"path"
"strings"

"nhooyr.io/websocket/internal/errd"
Expand All@@ -41,8 +41,8 @@ type AcceptOptions struct {
// One would set this field to []string{"example.com"} to authorize example.com to connect.
//
// Each pattern is matched case insensitively against the request origin host
// withfilepath.Match.
// See https://golang.org/pkg/path/filepath/#Match
// withpath.Match.
// See https://golang.org/pkg/path/#Match
//
// Please ensure you understand the ramifications of enabling this.
// If used incorrectly your WebSocket server will be open to CSRF attacks.
Expand DownExpand Up@@ -96,7 +96,7 @@ func accept(w http.ResponseWriter, r *http.Request, opts *AcceptOptions) (_ *Con
if !opts.InsecureSkipVerify {
err = authenticateOrigin(r, opts.OriginPatterns)
if err != nil {
if errors.Is(err,filepath.ErrBadPattern) {
if errors.Is(err,path.ErrBadPattern) {
log.Printf("websocket: %v", err)
err = errors.New(http.StatusText(http.StatusForbidden))
}
Expand DownExpand Up@@ -221,7 +221,7 @@ func authenticateOrigin(r *http.Request, originHosts []string) error {
for _, hostPattern := range originHosts {
matched, err := match(hostPattern, u.Host)
if err != nil {
return fmt.Errorf("failed to parsefilepath pattern %q: %w", hostPattern, err)
return fmt.Errorf("failed to parsepath pattern %q: %w", hostPattern, err)
}
if matched {
return nil
Expand All@@ -234,7 +234,7 @@ func authenticateOrigin(r *http.Request, originHosts []string) error {
}

func match(pattern, s string) (bool, error) {
returnfilepath.Match(strings.ToLower(pattern), strings.ToLower(s))
returnpath.Match(strings.ToLower(pattern), strings.ToLower(s))
}

func selectSubprotocol(r *http.Request, subprotocols []string) string {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp