Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace references to SafeStyle with string
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 701038552
Soy Authors authored and copybara-github committed Dec 3, 2024
1 parent 5f30e7a commit 2e93422
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion documentation/reference/types.md
Original file line number Diff line number Diff line change
@@ -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`
3 changes: 1 addition & 2 deletions java/src/com/google/template/soy/jssrc/internal/JsType.java
Original file line number Diff line number Diff line change
@@ -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:
10 changes: 4 additions & 6 deletions javascript/soydata_converters.js
Original file line number Diff line number Diff line change
@@ -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);
};

0 comments on commit 2e93422

Please sign in to comment.