• Caleb Spare's avatar
    html/template: fix Clone so that t.Lookup(t.Name()) yields t · cd2c9df7
    Caleb Spare authored
    Template.escape makes the assumption that t.Lookup(t.Name()) is t
    (escapeTemplate looks up the associated template by name and sets
    escapeErr appropriately).
    
    This assumption did not hold for a Cloned template, because the template
    associated with t.Name() was a second copy of the original.
    
    Add a test for the assumption that t.Lookup(t.Name()) == t.
    
    One effect of this broken assumption was #16101: parallel Executes
    racily accessed the template namespace because each Execute call saw
    t.escapeErr == nil and re-escaped the template concurrently with read
    accesses occurring outside the namespace mutex.
    
    Add a test for this race.
    
    Related to #12996 and CL 16104.
    
    Fixes #16101
    
    Change-Id: I59831d0847abbabb4ef9135f2912c6ce982f9837
    Reviewed-on: https://go-review.googlesource.com/31092
    Run-TryBot: Rob Pike <r@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRob Pike <r@golang.org>
    cd2c9df7
Name
Last commit
Last update
..
attr.go Loading commit data...
clone_test.go Loading commit data...
content.go Loading commit data...
content_test.go Loading commit data...
context.go Loading commit data...
css.go Loading commit data...
css_test.go Loading commit data...
doc.go Loading commit data...
error.go Loading commit data...
escape.go Loading commit data...
escape_test.go Loading commit data...
example_test.go Loading commit data...
examplefiles_test.go Loading commit data...
html.go Loading commit data...
html_test.go Loading commit data...
js.go Loading commit data...
js_test.go Loading commit data...
template.go Loading commit data...
template_test.go Loading commit data...
transition.go Loading commit data...
transition_test.go Loading commit data...
url.go Loading commit data...
url_test.go Loading commit data...