You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice that the interpolated fragment separator #, and the & sub-delimiter is escaped (via percent-encoding) in the first template, but not the second, despite the fact that both URLs are equivalent (%3F is the percent encoding of ?). This allows parameters and fragments to be injected into the URL in the second template.
The problem is that the state machine only transitions into the URL query/frag component state when the # or ? rune is found. It does not account for their percent-encoded equivalents.
The fix for this is simple, but it would break users by changing html/template's URL-escaping behavior. I'm not sure if such a change would be worth it.
The text was updated successfully, but these errors were encountered:
Are the URLs really equivalent? I would not expect %3F to behave like the unquoted question mark -- how else would you quote a question mark that is part of the URL path?
@tv42@opennota Thanks for pointing that out. I once again confused myself over how percent-encoded and HTML-escaped characters get interpreted by the browser.
My concern should have been if ? in <a href="http://www.foo.com/bar?{{.}}">link</a> is properly un-escaped into ?, and interpreted by the URL parser. As it turns out, it is, and the action after the HTML-escaped question mark gets query-escaped properly.
Given the following two templates:
When
.
is"hello#param1=value1¶m2=value2"
, the templates produce the following HTML output:Example at https://play.golang.org/p/pbdV0f9DdE.
Notice that the interpolated fragment separator
#
, and the&
sub-delimiter is escaped (via percent-encoding) in the first template, but not the second, despite the fact that both URLs are equivalent (%3F
is the percent encoding of?
). This allows parameters and fragments to be injected into the URL in the second template.The problem is that the state machine only transitions into the URL query/frag component state when the
#
or?
rune is found. It does not account for their percent-encoded equivalents.The fix for this is simple, but it would break users by changing html/template's URL-escaping behavior. I'm not sure if such a change would be worth it.
The text was updated successfully, but these errors were encountered: