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

Allow parse etag without quotes #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

LugaMuga
Copy link

Catched issue same like #50.
Understand that it's needs when server not working strictly by RFC. But some developers will try to use library for "wrong implemented" servers and get the same error.
Think it's possible to make requirement not so strictly in that case.

.gitignore Outdated
# JetBrains GoLand
.idea
*.iml
*.ipr
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't commit editor-specific ignore rules.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will remove it.

@@ -342,7 +342,8 @@ type ETag string
func (etag *ETag) UnmarshalText(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return fmt.Errorf("webdav: failed to unquote ETag: %v", err)
*etag = ETag(b)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this completely ignores all errors. Not sure this is a great idea.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. But how we can logged error with warn status?

@emersion
Copy link
Owner

TBH, maybe we shouldn't do any of the quoting/unquoting stuff. It would be a bit awkward to deal with quoted strings, but at least we wouldn't have this kind of issues and we would handle weak entity tags properly.

@LugaMuga
Copy link
Author

Agree. But what will happen with projects, that already use this library?
I don't think that they have tests for quotes, and this change can broke them.

@emersion
Copy link
Owner

We've already made plenty of breaking changes since the last release.

@LugaMuga
Copy link
Author

LugaMuga commented May 3, 2022

ok, changed patch as you said

Copy link
Owner

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String and MarshalText should be dropped as well, otherwise ETags will get double-quoted.

.gitignore Outdated
@@ -11,4 +11,4 @@
*.out

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change this file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted all changes

@@ -340,11 +340,7 @@ type GetETag struct {
type ETag string

func (etag *ETag) UnmarshalText(b []byte) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is now a no-op and can be dropped.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@LugaMuga
Copy link
Author

LugaMuga commented May 3, 2022

String and MarshalText should be dropped as well, otherwise ETags will get double-quoted.

Done

@emersion
Copy link
Owner

Hm, this new proposal is error-prone. Library users need to "guess" that they need to double-quote the ETag values they're using. It's very easy to break the RFC with this API.

@LugaMuga
Copy link
Author

That's why I worried about remove String method.
Let's I return it and in server call internal.ETag(ao.ETag).String() ?

@emersion
Copy link
Owner

string(ao.ETag) should work as well.

@LugaMuga
Copy link
Author

Nope. String() method, that I was removed, is adding quotes to ETag value.
This is not the same string(ao.ETag)

@emersion
Copy link
Owner

With your changes, the ETag contains quotes already, no need to add them again.

@LugaMuga
Copy link
Author

Where my changes add quotes in code ?
w.Header().Set("ETag", ao.ETag)

@LugaMuga
Copy link
Author

Removed wrapper, with call String() method on it. I think it will broke server in setting ETag to headers

@LugaMuga
Copy link
Author

Could you please explain, why need write type conversion here?

Screenshot 2022-06-14 at 20 57 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants