Skip to content

Commit

Permalink
Change variable names in htmlinject to conform to linters
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara Mihali authored and kele committed Oct 20, 2020
1 parent c0ab760 commit 8cf1947
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions safehttp/plugins/htmlinject/htmlinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ func Transform(src io.Reader, cfg ...TransformConfig) (string, error) {

// LoadConfig is a configuration to use with loaders when processing a template.
type LoadConfig struct {
// DisableCsp disables CSP autononcing
DisableCsp bool
// DisableXsrf disables XSRF token injection
DisableXsrf bool
// DisableCSP disables CSP autononcing
DisableCSP bool
// DisableXSRF disables XSRF token injection
DisableXSRF bool
}

// LoadTrustedTemplate processes the given TrustedTemplate with the specified default configurations and
Expand All @@ -138,11 +138,11 @@ func LoadTrustedTemplate(tpl *template.Template, lcfg LoadConfig, src template.T
panic("this function should never be called, templates should be cloned and injected with the noncing functions, not executed directly")
}
funcMap := map[string]interface{}{}
if !lcfg.DisableCsp {
if !lcfg.DisableCSP {
cfg = append(cfg, CSPNoncesDefault)
funcMap[CSPNoncesDefaultFuncName] = noop
}
if !lcfg.DisableXsrf {
if !lcfg.DisableXSRF {
cfg = append(cfg, XSRFTokensDefault)
funcMap[XSRFTokensDefaultFuncName] = noop
}
Expand Down
2 changes: 1 addition & 1 deletion safehttp/plugins/htmlinject/htmlinject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func TestTransform(t *testing.T) {
func TestLoadTrustedTemplateWithDefaultConfig(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := LoadConfig{DisableCsp: !tt.csp, DisableXsrf: !tt.xsrf}
cfg := LoadConfig{DisableCSP: !tt.csp, DisableXSRF: !tt.xsrf}
gotTpl, err := LoadTrustedTemplate(nil, cfg, uncheckedconversions.TrustedTemplateFromStringKnownToSatisfyTypeContract(tt.in))
if err != nil {
t.Fatalf("LoadTrustedTemplate: got err %q", err)
Expand Down

0 comments on commit 8cf1947

Please sign in to comment.