checkTraversal returns an error if any component is exactly "..". Such a component survives percent-encoding as a real path segment and would traverse the URL path. A single "." is left alone because it does not traverse and is a legitimate value in some paths.
(components []string)
| 73 | // A single "." is left alone because it does not traverse and is a legitimate value |
| 74 | // in some paths. |
| 75 | func checkTraversal(components []string) error { |
| 76 | for _, c := range components { |
| 77 | if c == ".." { |
| 78 | return fmt.Errorf("path component %q would traverse the URL path", c) |
| 79 | } |
| 80 | } |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | func (u *MutableSafeURL) sealed() {} |
| 85 |
no test coverage detected