-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
html/template: confusing or incorrect error #2644
Labels
Milestone
Comments
I agree that the error message needs to be improved. In the case where $.Draft is truthy, we have where we need to HTML escape .Name but do nothing else. In the other case, we have where we need to ensure that .Name does not start with "javascript:" or another disallowed protocol. The "ambiguous URL context" error message indicates that it is impossible to tell statically, whether to white-list protocols or not. In your case, we could probably %-encode any colon, but that is not possible in general because colons are overloaded and would be bending the rules of RFC 3986. It is ambiguous whether the colon follows a non-hierarchical protocol or precedes a port. We could factor the interpolation left into the conditional and that may match programmer intent, but that is not possible across template call boundaries: |
Shouldn't the factored version be: ?? |
krolaw, I think you're right that the factored form is missing a slash. If it were factored to there would be no error. |
The original error was (action: [(command: [F=[Name]])]) appears in an ambiguous URL context The trivial thing is that it would be nice to use the template syntax in the error, so that it would say {.Name} appears in an ambiguous URL context Slightly less trivially, it would be nice to list the contexts in some friendly way. For example, in this case, {.Name} appears in an ambiguous context: either beginning or middle of URL |
Owner changed to builder@golang.org. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: