Provide nonce as String, not Optional<String>, to Soy Otherwise, when the nonce is available the index page fails to load, with "500 Internal Server Error", due to the server-side exception "IllegalArgumentException: Unable to convert param csp_nonce to a SoyValue". Noticed via a Google-internal integration test. Tested by re-running the same test with this change applied. Google-Bug-Id: b/33429040 Change-Id: I98fc6ea267eff6a332e1345f79a4e7bbf51376a7
diff --git a/java/com/google/gitiles/Renderer.java b/java/com/google/gitiles/Renderer.java index 3b85e3d..3bf9754 100644 --- a/java/com/google/gitiles/Renderer.java +++ b/java/com/google/gitiles/Renderer.java
@@ -238,7 +238,7 @@ .put("SITE_TITLE", siteTitle); Optional<String> nonce = req.map((r) -> (String) r.getAttribute("nonce")); if (nonce.isPresent() && nonce.get() != null) { - ij.put("csp_nonce", nonce); + ij.put("csp_nonce", nonce.get()); } return getSauce().renderTemplate(templateName).setIj(ij.build()); }