Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/webdav: Wrong name0 passed to Confirm() with Handler prefix. #15967

Closed
yonderblue opened this issue Jun 6, 2016 · 2 comments
Closed

x/net/webdav: Wrong name0 passed to Confirm() with Handler prefix. #15967

yonderblue opened this issue Jun 6, 2016 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@yonderblue
Copy link

yonderblue commented Jun 6, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go1.7beta1 and go1.6
  2. What operating system and processor architecture are you using (go env)?
    linux amd64
  3. What did you do?
    Install davfs and sudo mount -t davfs 'http://127.0.0.1/some/path/prefix/theresource' /tmp/dav
    Run the http server with the webdav handler:
&webdav.Handler{
    "/some/path/prefix",
    NewMemFS(),
    NewMemLS(),
    func(r *http.Request, err error) {
        fmt.Println(r.Method, r.Header, err)
    },

Touch a file.

  1. What did you expect to see?
    Success!
  2. What did you see instead?
    The PUT request had a "webdav: locked" error.
    When printing the inside the following function found in lock.go int he webdav package:
func (m *memLS) lookup(name string, conditions ...Condition) (n *memLSNode) {
    // TODO: support Condition.Not and Condition.ETag.
    for _, c := range conditions {
        n = m.byToken[c.Token]
        fmt.Println("HERE!", c, n, name)
        if n == nil || n.held {
            continue
        }
        if name == n.details.Root {
            return n
        }
        if n.details.ZeroDepth {
            continue
        }
        if n.details.Root == "/" || strings.HasPrefix(name, n.details.Root+"/") {
            return n
        }
    }
    return nil
}

name is "/some/path/prefix/theresource" while n.details.Root is "/theresource" :(

Problem seems to be here https://github.com/golang/net/blob/master/webdav/webdav.go#L151
I have verified that if you put the following instead of line 151:

reqPath, status, err := h.stripPrefix(u.Path)
if err != nil {
    return nil, status, err
}
lsrc = reqPath

it solves the issue in my case.

@adg adg changed the title webdav NewMemLS() doesn't support Handler prefix. x/net/webdav: NewMemLS doesn't support Handler prefix. Jun 6, 2016
@adg adg added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 6, 2016
@adg adg added this to the Unplanned milestone Jun 6, 2016
@yonderblue yonderblue changed the title x/net/webdav: NewMemLS doesn't support Handler prefix. x/net/webdav: Wrong name0 passed to Confirm() with Handler prefix. Jun 6, 2016
@gopherbot
Copy link

CL https://golang.org/cl/24023 mentions this issue.

@nigeltao
Copy link
Contributor

Thanks for the great bug report and diagnosis.

@golang golang locked and limited conversation to collaborators Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants