com.google.clearsilver.jsilver.syntax
Class AutoEscaper
java.lang.Object
com.google.clearsilver.jsilver.syntax.analysis.AnalysisAdapter
com.google.clearsilver.jsilver.syntax.analysis.DepthFirstAdapter
com.google.clearsilver.jsilver.syntax.AutoEscaper
- All Implemented Interfaces:
- Analysis, Switch
public class AutoEscaper
- extends DepthFirstAdapter
Run a context parser (currently only HTML parser) over the AST, determine nodes that need
escaping, and apply the appropriate escaping command to those nodes. The parser is fed literal
data (from DataCommands), which it uses to track the context. When variables (e.g. VarCommand)
are encountered, we query the parser for its current context, and apply the appropriate escaping
command.
Methods inherited from class com.google.clearsilver.jsilver.syntax.analysis.DepthFirstAdapter |
caseAAddExpression, caseAAndExpression, caseAAutoescapeCommand, caseACommaExpression, caseACommentCommand, caseADecimalExpression, caseADecNumberVariable, caseADescendVariable, caseADivideExpression, caseAEachCommand, caseAEqExpression, caseAExistsExpression, caseAExpandVariable, caseAFunctionExpression, caseAGteExpression, caseAGtExpression, caseAHexExpression, caseAHexNumberVariable, caseAInlineCommand, caseALoopCommand, caseALoopIncCommand, caseALoopToCommand, caseALteExpression, caseALtExpression, caseAModuloExpression, caseAMultipleCommand, caseAMultiplyExpression, caseANameVariable, caseANeExpression, caseANegativeExpression, caseANoopCommand, caseANoopExpression, caseANotExpression, caseANumericAddExpression, caseANumericEqExpression, caseANumericExpression, caseANumericNeExpression, caseAOrExpression, caseASequenceExpression, caseASetCommand, caseAStringExpression, caseASubtractExpression, caseAVariableExpression, caseAWithCommand, defaultIn, defaultOut, inAAddExpression, inAAltCommand, inAAndExpression, inAAutoescapeCommand, inACallCommand, inACommaExpression, inACommentCommand, inAContentTypeCommand, inACsOpenPosition, inADataCommand, inADecimalExpression, inADecNumberVariable, inADefCommand, inADescendVariable, inADivideExpression, inAEachCommand, inAEqExpression, inAEscapeCommand, inAEvarCommand, inAExistsExpression, inAExpandVariable, inAFunctionExpression, inAGteExpression, inAGtExpression, inAHardIncludeCommand, inAHardLincludeCommand, inAHexExpression, inAHexNumberVariable, inAIfCommand, inAIncludeCommand, inAInlineCommand, inALincludeCommand, inALoopCommand, inALoopIncCommand, inALoopToCommand, inALteExpression, inALtExpression, inALvarCommand, inAModuloExpression, inAMultipleCommand, inAMultiplyExpression, inANameCommand, inANameVariable, inANeExpression, inANegativeExpression, inANoopCommand, inANoopExpression, inANotExpression, inANumericAddExpression, inANumericEqExpression, inANumericExpression, inANumericNeExpression, inAOrExpression, inASequenceExpression, inASetCommand, inAStringExpression, inASubtractExpression, inAUvarCommand, inAVarCommand, inAVariableExpression, inAWithCommand, inStart, outAAddExpression, outAAltCommand, outAAndExpression, outAAutoescapeCommand, outACallCommand, outACommaExpression, outACommentCommand, outAContentTypeCommand, outACsOpenPosition, outADataCommand, outADecimalExpression, outADecNumberVariable, outADefCommand, outADescendVariable, outADivideExpression, outAEachCommand, outAEqExpression, outAEscapeCommand, outAEvarCommand, outAExistsExpression, outAExpandVariable, outAFunctionExpression, outAGteExpression, outAGtExpression, outAHardIncludeCommand, outAHardLincludeCommand, outAHexExpression, outAHexNumberVariable, outAIfCommand, outAIncludeCommand, outAInlineCommand, outALincludeCommand, outALoopCommand, outALoopIncCommand, outALoopToCommand, outALteExpression, outALtExpression, outALvarCommand, outAModuloExpression, outAMultipleCommand, outAMultiplyExpression, outANameCommand, outANameVariable, outANeExpression, outANegativeExpression, outANoopCommand, outANoopExpression, outANotExpression, outANumericAddExpression, outANumericEqExpression, outANumericExpression, outANumericNeExpression, outAOrExpression, outASequenceExpression, outASetCommand, outAStringExpression, outASubtractExpression, outAUvarCommand, outAVarCommand, outAVariableExpression, outAWithCommand, outStart |
Methods inherited from class com.google.clearsilver.jsilver.syntax.analysis.AnalysisAdapter |
caseEOF, caseTAlt, caseTAnd, caseTArgWhitespace, caseTAssignment, caseTAutoescape, caseTBang, caseTBracketClose, caseTBracketOpen, caseTCall, caseTComma, caseTCommandDelimiter, caseTComment, caseTCommentStart, caseTContentType, caseTCsClose, caseTCsOpen, caseTData, caseTDecNumber, caseTDef, caseTDollar, caseTDot, caseTEach, caseTElse, caseTElseIf, caseTEq, caseTEscape, caseTEvar, caseTGt, caseTGte, caseTHardDelimiter, caseTHash, caseTHexNumber, caseTIf, caseTInclude, caseTInline, caseTLinclude, caseTLoop, caseTLt, caseTLte, caseTLvar, caseTMinus, caseTName, caseTNe, caseTOr, caseTParenClose, caseTParenOpen, caseTPercent, caseTPlus, caseTQuestion, caseTSet, caseTSlash, caseTStar, caseTString, caseTUvar, caseTVar, caseTWith, caseTWord, defaultCase, getIn, getOut, setIn, setOut |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AutoEscaper
public AutoEscaper(EscapeMode mode,
String templateName)
- Create an AutoEscaper, which will apply the specified escaping mode. If templateName is
non-null, it will be used while displaying error messages.
- Parameters:
mode
- templateName
-
AutoEscaper
public AutoEscaper(EscapeMode mode)
- Create an AutoEscaper, which will apply the specified escaping mode. When possible, use
#AutoEscaper(EscapeMode, String) instead. It specifies the template being auto escaped, which
is useful when displaying error messages.
- Parameters:
mode
-
caseStart
public void caseStart(Start start)
- Specified by:
caseStart
in interface Analysis
- Overrides:
caseStart
in class DepthFirstAdapter
caseADataCommand
public void caseADataCommand(ADataCommand node)
- Specified by:
caseADataCommand
in interface Analysis
- Overrides:
caseADataCommand
in class DepthFirstAdapter
caseADefCommand
public void caseADefCommand(ADefCommand node)
- Specified by:
caseADefCommand
in interface Analysis
- Overrides:
caseADefCommand
in class DepthFirstAdapter
caseAIfCommand
public void caseAIfCommand(AIfCommand node)
- Specified by:
caseAIfCommand
in interface Analysis
- Overrides:
caseAIfCommand
in class DepthFirstAdapter
caseAEscapeCommand
public void caseAEscapeCommand(AEscapeCommand node)
- Specified by:
caseAEscapeCommand
in interface Analysis
- Overrides:
caseAEscapeCommand
in class DepthFirstAdapter
caseACallCommand
public void caseACallCommand(ACallCommand node)
- Specified by:
caseACallCommand
in interface Analysis
- Overrides:
caseACallCommand
in class DepthFirstAdapter
caseALvarCommand
public void caseALvarCommand(ALvarCommand node)
- Specified by:
caseALvarCommand
in interface Analysis
- Overrides:
caseALvarCommand
in class DepthFirstAdapter
caseAEvarCommand
public void caseAEvarCommand(AEvarCommand node)
- Specified by:
caseAEvarCommand
in interface Analysis
- Overrides:
caseAEvarCommand
in class DepthFirstAdapter
caseALincludeCommand
public void caseALincludeCommand(ALincludeCommand node)
- Specified by:
caseALincludeCommand
in interface Analysis
- Overrides:
caseALincludeCommand
in class DepthFirstAdapter
caseAIncludeCommand
public void caseAIncludeCommand(AIncludeCommand node)
- Specified by:
caseAIncludeCommand
in interface Analysis
- Overrides:
caseAIncludeCommand
in class DepthFirstAdapter
caseAHardLincludeCommand
public void caseAHardLincludeCommand(AHardLincludeCommand node)
- Specified by:
caseAHardLincludeCommand
in interface Analysis
- Overrides:
caseAHardLincludeCommand
in class DepthFirstAdapter
caseAHardIncludeCommand
public void caseAHardIncludeCommand(AHardIncludeCommand node)
- Specified by:
caseAHardIncludeCommand
in interface Analysis
- Overrides:
caseAHardIncludeCommand
in class DepthFirstAdapter
caseAVarCommand
public void caseAVarCommand(AVarCommand node)
- Specified by:
caseAVarCommand
in interface Analysis
- Overrides:
caseAVarCommand
in class DepthFirstAdapter
caseAAltCommand
public void caseAAltCommand(AAltCommand node)
- Specified by:
caseAAltCommand
in interface Analysis
- Overrides:
caseAAltCommand
in class DepthFirstAdapter
caseANameCommand
public void caseANameCommand(ANameCommand node)
- Specified by:
caseANameCommand
in interface Analysis
- Overrides:
caseANameCommand
in class DepthFirstAdapter
caseAUvarCommand
public void caseAUvarCommand(AUvarCommand node)
- Specified by:
caseAUvarCommand
in interface Analysis
- Overrides:
caseAUvarCommand
in class DepthFirstAdapter
caseAContentTypeCommand
public void caseAContentTypeCommand(AContentTypeCommand node)
- Handles a <?cs content-type: "content type" ?> command.
This command is used when the auto escaping context of a template cannot be determined from its
contents - for example, a CSS stylesheet or a javascript source file. Note that <?cs
content-type: ?> command is not required for all javascript and css templates. If the
template contains a <script> or <style> tag (or is included from another template
within the right tag), auto escaping will recognize the tag and switch context accordingly. On
the other hand, if the template serves a resource that is loaded via a <script src= > or
<link rel > command, the explicit <?cs content-type: ?> command would be required.
- Specified by:
caseAContentTypeCommand
in interface Analysis
- Overrides:
caseAContentTypeCommand
in class DepthFirstAdapter
caseACsOpenPosition
public void caseACsOpenPosition(ACsOpenPosition node)
- Specified by:
caseACsOpenPosition
in interface Analysis
- Overrides:
caseACsOpenPosition
in class DepthFirstAdapter
Copyright © 2010-2012 Google. All Rights Reserved.