From 2e934227c9421dc940005879d42fe1e75d2e1cdb Mon Sep 17 00:00:00 2001 From: Soy Authors Date: Thu, 28 Nov 2024 08:49:33 -0800 Subject: [PATCH] Replace references to SafeStyle with string PiperOrigin-RevId: 701038552 --- documentation/reference/types.md | 2 +- .../com/google/template/soy/jssrc/internal/JsType.java | 3 +-- javascript/soydata_converters.js | 10 ++++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/documentation/reference/types.md b/documentation/reference/types.md index b0cf10bcbc..1c64d6a9ef 100644 --- a/documentation/reference/types.md +++ b/documentation/reference/types.md @@ -262,7 +262,7 @@ change in the future. Backend | type in host language ---------- | --------------------------------------------------------- -JavaScript | `goog.soy.data.SanitizedCss`, `safevalues.SafeStyle` +JavaScript | `goog.soy.data.SanitizedCss`, `string` SoySauce | `string`, `com.google.template.soy.data.SanitizedContent` Tofu | `com.google.template.soy.data.SanitizedContent` Python | `sanitize.SanitizedCss`, `html_types.SafeStyleSheet` diff --git a/java/src/com/google/template/soy/jssrc/internal/JsType.java b/java/src/com/google/template/soy/jssrc/internal/JsType.java index 8ff16a5080..5d82b5a852 100644 --- a/java/src/com/google/template/soy/jssrc/internal/JsType.java +++ b/java/src/com/google/template/soy/jssrc/internal/JsType.java @@ -878,8 +878,7 @@ private static JsType createSanitized(SanitizedContentKind kind, boolean isStric // content. using these wide unions everywhere is confusing. switch (kind) { case CSS: - builder.addType("!safevalues.SafeStyle"); - builder.addRequire(GoogRequire.createTypeRequire("safevalues")); + builder.addType("string"); break; case HTML_ELEMENT: case HTML: diff --git a/javascript/soydata_converters.js b/javascript/soydata_converters.js index 148e676481..ad5301dd63 100644 --- a/javascript/soydata_converters.js +++ b/javascript/soydata_converters.js @@ -44,7 +44,7 @@ const googString = goog.require('goog.string'); const soy = goog.require('soy'); const {ByteString} = goog.require('jspb.bytestring'); const {SanitizedCss, SanitizedHtml, SanitizedJs, SanitizedTrustedResourceUri, SanitizedUri} = goog.require('goog.soy.data'); -const {htmlSafeByReview, resourceUrlSafeByReview, scriptSafeByReview, styleSafeByReview, styleSheetSafeByReview, urlSafeByReview} = goog.require('safevalues.restricted.reviewed'); +const {htmlSafeByReview, resourceUrlSafeByReview, scriptSafeByReview, styleSheetSafeByReview, urlSafeByReview} = goog.require('safevalues.restricted.reviewed'); const {htmlToProto, protoToHtml, protoToResourceUrl, protoToScript, protoToStyle, protoToStyleSheet, protoToUrl, resourceUrlToProto, scriptToProto, styleSheetToProto, styleToProto, urlToProto} = goog.require('safevalues.conversions.jspb'); const {unwrapHtml, unwrapResourceUrl, unwrapScript, unwrapStyleSheet, unwrapUrl} = goog.require('safevalues'); @@ -72,11 +72,9 @@ exports.packSanitizedCssToSafeStyleProtoSoyRuntimeOnly = function( throw new Error('Consider using packSanitizedCssToSafeStyleSheetProto().'); } - const safeStyle = styleSafeByReview( - sanitizedCss ? - /** @type {!SanitizedCss} */ (sanitizedCss).getContent() : - '', - {justification: 'from Soy SanitizedCss object'}); + const safeStyle = sanitizedCss ? + /** @type {!SanitizedCss} */ (sanitizedCss).getContent() : + ''; return styleToProto(safeStyle); };