public class FastArchivalUrlReplayParseEventHandler extends Object implements ParseEventHandler
This class has kludgy support for disabling JavaScript inclusion
with <SCRIPT SRC=...> element. jsBlockTrans,
whose primary use is translating JavaScript code block (inline <SCRIPT>,
javascript: URI in HREF attribute, and event
handler attributes), is also called with a value of SRC attribute
of <SCRIPT> tag. If jsBlockTrans returns either null
or an empty String, <SCRIPT> element is disabled by changing SRC to
an empty value. Note that in this case jsBlockTrans is used only for
a test, and its return value is simply discarded.
URL translation is done by a subsequent call to URLStringTransformer for
js_ context. This feature is very likely a subject of refactoring
in the future.
| Modifier and Type | Field and Description |
|---|---|
static String |
FERRET_DONE_KEY |
protected static String |
FERRET_HEAD_INSERTED |
protected static String |
FERRET_IN_HEAD |
protected String |
headInsertJsp |
| Constructor and Description |
|---|
FastArchivalUrlReplayParseEventHandler()
Constructor...
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
bodyInsertContent(ReplayParseContext context)
return body-insert text.
|
protected boolean |
checkAllowTag(ParseContext context,
org.htmlparser.nodes.TagNode tagNode) |
protected void |
emit(ReplayParseContext context,
String pre,
org.htmlparser.Node node,
String post) |
protected void |
emitHeadInsert(ReplayParseContext context,
org.htmlparser.Node node,
boolean postInsert) |
AttributeRewriter |
getAttributeRewriter() |
String |
getCommentJsp()
Deprecated.
use getEndJsp()
|
String |
getEndJsp() |
String |
getHeadInsertJsp() |
StringTransformer |
getJsBlockTrans() |
String |
getJspInsertPath() |
String |
getStartsp() |
void |
handleNode(ParseContext pContext,
org.htmlparser.Node node) |
void |
handleParseComplete(ParseContext pContext) |
void |
handleParseStart(ParseContext pContext) |
void |
init() |
boolean |
isUnescapeAttributeValues()
Deprecated.
1.8.1/05-23-2014 moved to
StandardAttributeRewriter. |
void |
setAttributeRewriter(AttributeRewriter attributeRewriter)
set
AttributeRewriter for rewriting attribute values. |
void |
setCommentJsp(String commentJsp)
Deprecated.
use setEndJsp()
|
void |
setEndJsp(String endJsp) |
void |
setHeadInsertJsp(String headInsertJsp)
servlet whose output will be
inserted right after
HEAD tag. |
void |
setJsBlockTrans(StringTransformer jsBlockTrans)
StringTransformer used for rewriting JavaScript code block
(
<SCRIPT> and javascript: attribute). |
void |
setJspInsertPath(String jspInsertPath) |
void |
setStartJsp(String startJsp) |
void |
setUnescapeAttributeValues(boolean unescapeAttributeValues)
Deprecated.
1.8.1/05-23-2014 property moved to
StandardAttributeRewriter
This property still works, but only with StandardAttributeRewriter. |
public static final String FERRET_DONE_KEY
protected static final String FERRET_IN_HEAD
protected static final String FERRET_HEAD_INSERTED
protected String headInsertJsp
public FastArchivalUrlReplayParseEventHandler()
public void init()
throws IOException
IOExceptionpublic void handleNode(ParseContext pContext, org.htmlparser.Node node) throws IOException
handleNode in interface ParseEventHandlerpContext - node - IOExceptionprotected boolean checkAllowTag(ParseContext context, org.htmlparser.nodes.TagNode tagNode)
protected void emit(ReplayParseContext context, String pre, org.htmlparser.Node node, String post) throws IOException
IOExceptionpublic void handleParseComplete(ParseContext pContext) throws IOException
handleParseComplete in interface ParseEventHandlerpContext - IOExceptionpublic void handleParseStart(ParseContext pContext) throws IOException
handleParseStart in interface ParseEventHandlerpContext - IOExceptionpublic void setAttributeRewriter(AttributeRewriter attributeRewriter)
AttributeRewriter for rewriting attribute values.
if not set, StandardAttributeRewriter will be used as default.attributeRewriter - AttributeRewriter instance.public AttributeRewriter getAttributeRewriter()
public String getJspInsertPath()
public void setJspInsertPath(String jspInsertPath)
jspInsertPath - the jspInsertPath to setpublic String getCommentJsp()
public void setCommentJsp(String commentJsp)
commentJsp - the commentJsp to setpublic String getStartsp()
public void setStartJsp(String startJsp)
startJsp - The path to the JSP to execute and include at the start
of the documentpublic String getEndJsp()
public void setEndJsp(String endJsp)
endJsp - the path to the JSP to execute and include at the end
of the documentpublic StringTransformer getJsBlockTrans()
public void setJsBlockTrans(StringTransformer jsBlockTrans)
<SCRIPT> and javascript: attribute).
Also used (abused) as a test whether particular <SCRIPT SRC=...>
should be disabled (See class-level javadoc for details).jsBlockTrans - the jsBlockTrans to setpublic String getHeadInsertJsp()
public void setHeadInsertJsp(String headInsertJsp)
HEAD tag.headInsertJsp - context-relative pathprotected void emitHeadInsert(ReplayParseContext context, org.htmlparser.Node node, boolean postInsert) throws IOException
IOExceptionprotected String bodyInsertContent(ReplayParseContext context)
Run jspInsertPath and return its output as String.
if jspInsertPath is null, or body-insert should not be
inserted into the resource being processed, returns null.
context - context for the resource being processednull if no insertion shall be
made.public boolean isUnescapeAttributeValues()
StandardAttributeRewriter.true if attribute value unescape/re-escape
is enabled.public void setUnescapeAttributeValues(boolean unescapeAttributeValues)
StandardAttributeRewriter
This property still works, but only with StandardAttributeRewriter.By default, HTML entities (such as &)
in attribute values are unescaped before translation attempt,
and then escaped back before writing out. Although this is
supposedly the right thing to do, it has a side-effect: all
bare "&" (not escaped as "&")
will be replaced by "&". Setting this property
to false disables it.
As URL rewrite does neither parse nor modify query part, it
should mostly work without unescaping. But there may be some
corner cases where escaping is crucial. Don't set this to false
unless it's absolutely necessary.
unescapeAttributeValues - false to disable unescapingCopyright © 2005–2015 IIPC. All rights reserved.