ported over the HTML Checker from the original Venice source, somewhat improved
in design
This commit is contained in:
parent
2e395d636a
commit
92a569cbbd
|
@ -82,6 +82,10 @@
|
||||||
<database connection="data" namespaces="nscache" userproxy="users"/>
|
<database connection="data" namespaces="nscache" userproxy="users"/>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
|
<object name="htmlchecker" classname="com.silverwrist.dynamo.htmlcheck.HTMLCheckerManager" priority="5">
|
||||||
|
<database connection="data" namespaces="nscache"/>
|
||||||
|
</object>
|
||||||
|
|
||||||
<!-- Presentation and interface objects -->
|
<!-- Presentation and interface objects -->
|
||||||
<object name="remapper" classname="com.silverwrist.dynamo.servlet.RemapperData" priority="0">
|
<object name="remapper" classname="com.silverwrist.dynamo.servlet.RemapperData" priority="0">
|
||||||
<remap path="/verifyemail">
|
<remap path="/verifyemail">
|
||||||
|
|
|
@ -81,6 +81,10 @@
|
||||||
<database connection="data" namespaces="nscache" userproxy="users"/>
|
<database connection="data" namespaces="nscache" userproxy="users"/>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
|
<object name="htmlchecker" classname="com.silverwrist.dynamo.htmlcheck.HTMLCheckerManager" priority="5">
|
||||||
|
<database connection="data" namespaces="nscache"/>
|
||||||
|
</object>
|
||||||
|
|
||||||
<!-- Presentation and interface objects -->
|
<!-- Presentation and interface objects -->
|
||||||
<object name="remapper" classname="com.silverwrist.dynamo.servlet.RemapperData" priority="0">
|
<object name="remapper" classname="com.silverwrist.dynamo.servlet.RemapperData" priority="0">
|
||||||
<remap path="/verifyemail">
|
<remap path="/verifyemail">
|
||||||
|
|
|
@ -211,6 +211,30 @@ CREATE TABLE imagetype (
|
||||||
name VARCHAR(255) BINARY NOT NULL # image type name
|
name VARCHAR(255) BINARY NOT NULL # image type name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Table giving the names of all defined HTML checker profiles.
|
||||||
|
CREATE TABLE htmlprofiles (
|
||||||
|
profid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # profile identifier
|
||||||
|
nsid INT NOT NULL, # profile namespace ID
|
||||||
|
name VARCHAR(255) BINARY NOT NULL, # profile name
|
||||||
|
UNIQUE INDEX by_name (nsid, name)
|
||||||
|
);
|
||||||
|
|
||||||
|
# Properties that make up each HTML checker profile.
|
||||||
|
CREATE TABLE htmlprops (
|
||||||
|
profid INT NOT NULL, # profile identifier
|
||||||
|
nsid INT NOT NULL, # property namespace ID
|
||||||
|
prop_name VARCHAR(255) BINARY NOT NULL, # property name
|
||||||
|
prop_value VARCHAR(255), # property value
|
||||||
|
PRIMARY KEY (profid, nsid, prop_name)
|
||||||
|
);
|
||||||
|
|
||||||
|
# Table that indicates which HTML tag sets are permitted in which profiles.
|
||||||
|
CREATE TABLE htmltagsets (
|
||||||
|
profid INT NOT NULL, # profile identifier
|
||||||
|
tagset VARCHAR(64) NOT NULL, # tag set name
|
||||||
|
PRIMARY KEY (profid, tagset)
|
||||||
|
);
|
||||||
|
|
||||||
#### following this line are Venice-specific tables ####
|
#### following this line are Venice-specific tables ####
|
||||||
|
|
||||||
# The table which defines menus.
|
# The table which defines menus.
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,6 @@ public final class AnyCharMatcher
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private char[] charset; // the set of characters to look for
|
private char[] charset; // the set of characters to look for
|
||||||
private int[] locs; // a temporary array used for locations
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructors
|
* Constructors
|
||||||
|
@ -48,7 +47,6 @@ public final class AnyCharMatcher
|
||||||
public AnyCharMatcher(char[] charset)
|
public AnyCharMatcher(char[] charset)
|
||||||
{
|
{
|
||||||
this.charset = charset;
|
this.charset = charset;
|
||||||
this.locs = new int[charset.length];
|
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -60,7 +58,6 @@ public final class AnyCharMatcher
|
||||||
public AnyCharMatcher(String charset)
|
public AnyCharMatcher(String charset)
|
||||||
{
|
{
|
||||||
this.charset = charset.toCharArray();
|
this.charset = charset.toCharArray();
|
||||||
this.locs = new int[charset.length()];
|
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -83,32 +80,22 @@ public final class AnyCharMatcher
|
||||||
{
|
{
|
||||||
if (str==null)
|
if (str==null)
|
||||||
return -1;
|
return -1;
|
||||||
int numindexes = 0;
|
boolean found = false;
|
||||||
int i;
|
int rc = Integer.MAX_VALUE;
|
||||||
for (i=0; i<charset.length; i++)
|
for (int i=0; (rc>0) && (i<charset.length); i++)
|
||||||
{ // locate the index of the first HTML character
|
{ // get the index of this character
|
||||||
int tmp = str.indexOf(charset[i]);
|
int tmp = str.indexOf(charset[i]);
|
||||||
if (tmp>=0)
|
if (tmp>=0)
|
||||||
locs[numindexes++] = tmp;
|
{ // found a matching character
|
||||||
|
found = true;
|
||||||
|
if (tmp<rc)
|
||||||
|
rc = tmp;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
if (numindexes==0)
|
return (found ? rc : -1);
|
||||||
return -1; // no characters found
|
|
||||||
else if (numindexes==1)
|
|
||||||
return locs[0]; // only one found
|
|
||||||
|
|
||||||
int rc = locs[0];
|
|
||||||
for (i=1; i<numindexes; i++)
|
|
||||||
{ // this loop determines the lowest possible return value
|
|
||||||
if (rc==0)
|
|
||||||
return 0; // can't get any lower!
|
|
||||||
if (locs[i]<rc)
|
|
||||||
rc = locs[i]; // this is now the lowest
|
|
||||||
|
|
||||||
} // end for
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
} // end get
|
} // end get
|
||||||
|
|
||||||
|
@ -126,34 +113,23 @@ public final class AnyCharMatcher
|
||||||
{
|
{
|
||||||
if (str==null)
|
if (str==null)
|
||||||
return -1;
|
return -1;
|
||||||
|
boolean found = false;
|
||||||
int numindexes = 0;
|
int limit = str.length() - 1;
|
||||||
int i;
|
int rc = Integer.MIN_VALUE;
|
||||||
for (i=0; i<charset.length; i++)
|
for (int i=0; (rc<limit) && (i<charset.length); i++)
|
||||||
{ // locate the index of the first HTML character
|
{ // get the index of this character
|
||||||
int tmp = str.lastIndexOf(charset[i]);
|
int tmp = str.lastIndexOf(charset[i]);
|
||||||
if (tmp>=0)
|
if (tmp>=0)
|
||||||
locs[numindexes++] = tmp;
|
{ // found a matching character
|
||||||
|
found = true;
|
||||||
|
if (tmp>rc)
|
||||||
|
rc = tmp;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
if (numindexes==0)
|
return (found ? rc : -1);
|
||||||
return -1; // no characters found
|
|
||||||
else if (numindexes==1)
|
|
||||||
return locs[0]; // only one found
|
|
||||||
|
|
||||||
int rc = locs[0];
|
|
||||||
int limit = str.length() - 1;
|
|
||||||
for (i=1; i<numindexes; i++)
|
|
||||||
{ // this loop determines the highest possible return value
|
|
||||||
if (rc==limit)
|
|
||||||
return limit; // can't get any higher!
|
|
||||||
if (locs[i]>rc)
|
|
||||||
rc = locs[i]; // this is now the highest
|
|
||||||
|
|
||||||
} // end for
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
} // end getLast
|
} // end getLast
|
||||||
|
|
||||||
|
|
247
src/dynamo-framework/com/silverwrist/dynamo/HTMLTagSet.java
Normal file
247
src/dynamo-framework/com/silverwrist/dynamo/HTMLTagSet.java
Normal file
|
@ -0,0 +1,247 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import org.apache.commons.lang.enum.*;
|
||||||
|
|
||||||
|
public final class HTMLTagSet extends ValuedEnum
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* The actual enumeration values
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
// N.B.: The index values are from the old Venice code, for compatibility
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes all tags that affect "inline" formatting only, such as <EM> and <B>.
|
||||||
|
* These are usually allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet INLINE = new HTMLTagSet("INLINE",1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes the "A" tag.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet ANCHOR = new HTMLTagSet("ANCHOR",2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes all tags that affect "block-level" formatting, such as <P> and <Hn>.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet BLOCK = new HTMLTagSet("BLOCK",3);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes all tags that cause "active" content to be included in the HTML document, such as
|
||||||
|
* <OBJECT>, <APPLET>, and <SCRIPT>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet ACTIVECONTENT = new HTMLTagSet("ACTIVECONTENT",4);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes the tags that create clickable image maps, such as <AREA> and <MAP>.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet IMAGEMAP = new HTMLTagSet("IMAGEMAP",5);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes the tags that are used for document-level formatting and structure, such as <HTML>, <BODY>,
|
||||||
|
* and <TITLE>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet DOCUMENT = new HTMLTagSet("DOCUMENT",6);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes the <FONT> tag.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet FONT = new HTMLTagSet("FONT",7);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes all tags that are used in conjunction with forms, such as <FORM>, <INPUT>, and <SELECT>.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet FORMS = new HTMLTagSet("FORMS",8);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes all tags that are used in conjunction with tables, such as <TABLE>, <TR>, and <TD>.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet TABLES = new HTMLTagSet("TABLES",9);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes the <DEL> and <INS> tags, which are used for change markup.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet CHANGE = new HTMLTagSet("CHANGE",10);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes all tags related to frames, such as <FRAMESET> and <FRAME>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet FRAMES = new HTMLTagSet("FRAMES",11);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes the <IMG> tag.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet IMAGES = new HTMLTagSet("IMAGES",12);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes tags like <PRE>, which are used to preformat input text.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet PREFORMAT = new HTMLTagSet("PREFORMAT",13);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes Netscape-specific inline formatting, such as the hated <BLINK>.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet NSCP_INLINE = new HTMLTagSet("NSCP_INLINE",14);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes Netscape's layer tags, such as <LAYER> and <ILAYER>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet NSCP_LAYERS = new HTMLTagSet("NSCP_LAYERS",15);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes Netscape-specific form tags, like <KEYGEN>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet NSCP_FORMS = new HTMLTagSet("NSCP_FORMS",16);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes Netscape-specific block formatting tags, like <MULTICOL>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet NSCP_BLOCK = new HTMLTagSet("NSCP_BLOCK",17);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes the Netscape <SERVER> tag, used for server-side execution. This is generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet NSCP_SERVER = new HTMLTagSet("NSCP_SERVER",18);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes Microsoft-specific document formatting tags, such as <BGSOUND>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet MSFT_DOCUMENT = new HTMLTagSet("MSFT_DOCUMENT",19);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes Microsoft-specific inline formatting tags, such as <COMMENT>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet MSFT_INLINE = new HTMLTagSet("MSFT_INLINE",20);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes Microsoft-specific block formatting tags, such as <MARQUEE>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet MSFT_BLOCK = new HTMLTagSet("MSFT_BLOCK",21);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes Microsoft-specific active-content tags, such as <XML>. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet MSFT_ACTIVECONTENT = new HTMLTagSet("MSFT_ACTIVECONTENT",22);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes constructs for server-side page use only, such as with Microsoft Active Server Pages and Sun Java
|
||||||
|
* Server Pages. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet SERVER = new HTMLTagSet("SERVER",23);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes tags used by the Sun Java Server and other Java-compatible servers for including server-side components.
|
||||||
|
* These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet JAVASERVER = new HTMLTagSet("JAVASERVER",24);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes HTML comments. These are generally not allowed.
|
||||||
|
*/
|
||||||
|
public static final HTMLTagSet COMMENT = new HTMLTagSet("COMMENT",25);
|
||||||
|
|
||||||
|
public static final HTMLTagSet _LAST = COMMENT;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal constructor which creates a new element of this enumerated type.
|
||||||
|
*
|
||||||
|
* @param name The name of the <CODE>HTMLTagSet</CODE> to be created.
|
||||||
|
* @param value The numeric value to assign to the <CODE>HTMLTagSet</CODE>.
|
||||||
|
*/
|
||||||
|
private HTMLTagSet(String name, int value)
|
||||||
|
{
|
||||||
|
super(name,value);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Standard static method implementations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a <CODE>HTMLTagSet</CODE> by name.
|
||||||
|
*
|
||||||
|
* @param name The name of the <CODE>HTMLTagSet</CODE> to get; may be <CODE>null</CODE>.
|
||||||
|
* @return The <CODE>HTMLTagSet</CODE> object, or <CODE>null</CODE> if the <CODE>HTMLTagSet</CODE>
|
||||||
|
* does not exist.
|
||||||
|
*/
|
||||||
|
public static HTMLTagSet getEnum(String name)
|
||||||
|
{
|
||||||
|
return (HTMLTagSet)getEnum(HTMLTagSet.class,name);
|
||||||
|
|
||||||
|
} // end getEnum
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a <CODE>HTMLTagSet</CODE> by numeric value.
|
||||||
|
*
|
||||||
|
* @param code The numeric value of the <CODE>HTMLTagSet</CODE> to get.
|
||||||
|
* @return The <CODE>HTMLTagSet</CODE> object, or <CODE>null</CODE> if the <CODE>HTMLTagSet</CODE>
|
||||||
|
* does not exist.
|
||||||
|
*/
|
||||||
|
public static HTMLTagSet getEnum(int code)
|
||||||
|
{
|
||||||
|
return (HTMLTagSet)getEnum(HTMLTagSet.class,code);
|
||||||
|
|
||||||
|
} // end getEnum
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the <CODE>Map</CODE> of <CODE>HTMLTagSet</CODE> objects by name.
|
||||||
|
*
|
||||||
|
* @return The <CODE>HTMLTagSet</CODE> object <CODE>Map</CODE>.
|
||||||
|
*/
|
||||||
|
public static Map getEnumMap()
|
||||||
|
{
|
||||||
|
return getEnumMap(HTMLTagSet.class);
|
||||||
|
|
||||||
|
} // end getEnumMap
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the <CODE>List</CODE> of <CODE>HTMLTagSet</CODE> objects, in the order in which the objects are listed
|
||||||
|
* in the code above.
|
||||||
|
*
|
||||||
|
* @return The <CODE>HTMLTagSet</CODE> object <CODE>List</CODE>.
|
||||||
|
*/
|
||||||
|
public static List getEnumList()
|
||||||
|
{
|
||||||
|
return getEnumList(HTMLTagSet.class);
|
||||||
|
|
||||||
|
} // end getEnumList
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an iterator over all <CODE>HTMLTagSet</CODE> objects, in the order in which the objects are listed
|
||||||
|
* in the code above.
|
||||||
|
*
|
||||||
|
* @return The <CODE>HTMLTagSet</CODE> object iterator.
|
||||||
|
*/
|
||||||
|
public static Iterator iterator()
|
||||||
|
{
|
||||||
|
return iterator(HTMLTagSet.class);
|
||||||
|
|
||||||
|
} // end iterator
|
||||||
|
|
||||||
|
} // end class HTMLTagSet
|
|
@ -31,7 +31,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
* @author Eric J. Bowersox <erbo@silcom.com>
|
* @author Eric J. Bowersox <erbo@silcom.com>
|
||||||
* @version X
|
* @version X
|
||||||
*/
|
*/
|
||||||
public class HttpStatusCode extends ValuedEnum
|
public final class HttpStatusCode extends ValuedEnum
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* The actual enumeration values
|
* The actual enumeration values
|
||||||
|
|
|
@ -74,4 +74,10 @@ public interface Namespaces
|
||||||
public static final String GROUP_PERMISSIONS_NAMESPACE =
|
public static final String GROUP_PERMISSIONS_NAMESPACE =
|
||||||
"http://www.silverwrist.com/NS/dynamo/2002/12/27/group.permissions";
|
"http://www.silverwrist.com/NS/dynamo/2002/12/27/group.permissions";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespace for the base set of HTML Checker properties.
|
||||||
|
*/
|
||||||
|
public static final String HTMLCHECKER_PROPERTIES_NAMESPACE =
|
||||||
|
"http://www.silverwrist.com/NS/dynamo/2003/06/05/htmlchecker.properties";
|
||||||
|
|
||||||
} // end interface Namespaces
|
} // end interface Namespaces
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.except;
|
||||||
|
|
||||||
|
public class AlreadyFinishedException extends HTMLCheckerRuntimeException
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructors
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public AlreadyFinishedException()
|
||||||
|
{
|
||||||
|
super(AlreadyFinishedException.class,"DynamoExceptionMessages","htmlchecker.alreadyfinished");
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
} // end class AlreadyFinishedException
|
|
@ -31,3 +31,5 @@ scriptingException=Error executing {0}[{1}]: {2}
|
||||||
renderClass.creation=Unable to create object of class {0} at rendering time.
|
renderClass.creation=Unable to create object of class {0} at rendering time.
|
||||||
dialogException.xmlLoadException=Error in XML dialog definition: {0}
|
dialogException.xmlLoadException=Error in XML dialog definition: {0}
|
||||||
udfe.bad.itemType=No implementation exists for dialog item type "{0}".
|
udfe.bad.itemType=No implementation exists for dialog item type "{0}".
|
||||||
|
htmlchecker.alreadyfinished=The HTML Checker is already in a finished state.
|
||||||
|
htmlchecker.notyetfinished=The HTML Checker is not yet in a finished state.
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.except;
|
||||||
|
|
||||||
|
public class HTMLCheckerRuntimeException extends ExternalRuntimeException
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructors
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public HTMLCheckerRuntimeException(Class caller, String bundle, String message_id)
|
||||||
|
{
|
||||||
|
super(caller,bundle,message_id);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
public HTMLCheckerRuntimeException(Class caller, String bundle, String message_id, Throwable inner)
|
||||||
|
{
|
||||||
|
super(caller,bundle,message_id,inner);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
} // end class HtmlCheckerRuntimeException
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.except;
|
||||||
|
|
||||||
|
public class NotYetFinishedException extends HTMLCheckerRuntimeException
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructors
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public NotYetFinishedException()
|
||||||
|
{
|
||||||
|
super(NotYetFinishedException.class,"DynamoExceptionMessages","htmlchecker.notyetfinished");
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
} // end class NotYetFinishedException
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,128 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import com.silverwrist.util.*;
|
||||||
|
import com.silverwrist.dynamo.Namespaces;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
class EncodeHTML implements HTMLCheckerConfigurator, HTMLOutputFilter
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final String ESCAPED_CHARACTERS = "<>&";
|
||||||
|
|
||||||
|
private static final AnyCharMatcher MATCHER = new AnyCharMatcher(ESCAPED_CHARACTERS);
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
EncodeHTML()
|
||||||
|
{ // do nothing
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLCheckerConfigurator
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void configure(HTMLCheckerProfile profile)
|
||||||
|
{
|
||||||
|
boolean enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"enable.HTML.filter",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable) // add myself as an output filter
|
||||||
|
profile.addOutputFilter(this);
|
||||||
|
|
||||||
|
} // end configure
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLOutputFilter
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks and possibly outputs a character. If the character <CODE>ch</CODE> is '<',
|
||||||
|
* '>', or '&', it appends the appropriate string to the string buffer
|
||||||
|
* <CODE>buf</CODE> and returns <CODE>true</CODE>. If not, it returns <CODE>false</CODE>
|
||||||
|
* and leaves the buffer alone.
|
||||||
|
*
|
||||||
|
* @param buf The string buffer to append the character equivalent to.
|
||||||
|
* @param ch The character to be checked and possibly output.
|
||||||
|
* @return <CODE>true</CODE> if the character matches and was output, <CODE>false</CODE> if not.
|
||||||
|
*/
|
||||||
|
public boolean tryOutputCharacter(StringBuffer buf, char ch)
|
||||||
|
{
|
||||||
|
switch (ch)
|
||||||
|
{ // turn the HTML flag characters into appropriate entity escapes
|
||||||
|
case '<':
|
||||||
|
buf.append("<");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case '>':
|
||||||
|
buf.append(">");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case '&':
|
||||||
|
buf.append("&");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
} // end switch
|
||||||
|
|
||||||
|
return false; // bail out! not one we handle!
|
||||||
|
|
||||||
|
} // end tryOutputCharacter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <CODE>true</CODE> if the character <CODE>ch</CODE> is '<', '>', or '&', <CODE>false</CODE> if not.
|
||||||
|
*
|
||||||
|
* @param ch The character to be tested.
|
||||||
|
* @return <CODE>true</CODE> if the character <CODE>ch</CODE> is '<', '>', or '&', <CODE>false</CODE> if not.
|
||||||
|
*/
|
||||||
|
public boolean matchCharacter(char ch)
|
||||||
|
{
|
||||||
|
return (ESCAPED_CHARACTERS.indexOf(ch)>=0);
|
||||||
|
|
||||||
|
} // end matchCharacter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a character string, returns the total number of characters in that string, starting from the beginning,
|
||||||
|
* that are <I>not</I> handled by this filter before one that <I>is</I> appears. If none of the characters in this
|
||||||
|
* string are handled by the filter, the length of the string is returned.
|
||||||
|
*
|
||||||
|
* @param s The string to scan through.
|
||||||
|
* @return The length of the initial sequence of non-matching characters in this string.
|
||||||
|
*/
|
||||||
|
public int lengthNoMatch(String s)
|
||||||
|
{
|
||||||
|
int rc = MATCHER.get(s);
|
||||||
|
if (rc==-1)
|
||||||
|
rc = s.length();
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
} // end lengthNoMatch
|
||||||
|
|
||||||
|
} // end class EncodeHTML
|
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.Namespaces;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
class EncodeSQL implements HTMLCheckerConfigurator, HTMLOutputFilter
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
EncodeSQL()
|
||||||
|
{ // do nothing
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLCheckerConfigurator
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void configure(HTMLCheckerProfile profile)
|
||||||
|
{
|
||||||
|
boolean enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"enable.SQL.filter",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
{ // add myself as an output filter
|
||||||
|
profile.addOutputFilter(this);
|
||||||
|
profile.addRawOutputFilter(this);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
} // end configure
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLOutputFilter
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks and possibly outputs a character. If the character <CODE>ch</CODE> is an apostrophe, it appends two
|
||||||
|
* apostrophes to the string buffer <CODE>buf</CODE> and returns <CODE>true</CODE>. If not, it returns
|
||||||
|
* <CODE>false</CODE> and leaves the buffer alone.
|
||||||
|
*
|
||||||
|
* @param buf The string buffer to append the character equivalent to.
|
||||||
|
* @param ch The character to be checked and possibly output.
|
||||||
|
* @return <CODE>true</CODE> if the character matches and was output, <CODE>false</CODE> if not.
|
||||||
|
*/
|
||||||
|
public boolean tryOutputCharacter(StringBuffer buf, char ch)
|
||||||
|
{
|
||||||
|
if (ch=='\'')
|
||||||
|
{ // convert one apostrophe into two
|
||||||
|
buf.append("\'\'");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} // end tryOutputCharacter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <CODE>true</CODE> if the character <CODE>ch</CODE> is an apostrophe, <CODE>false</CODE> if not.
|
||||||
|
*
|
||||||
|
* @param ch The character to be tested.
|
||||||
|
* @return <CODE>true</CODE> if the character <CODE>ch</CODE> is an apostrophe, <CODE>false</CODE> if not.
|
||||||
|
*/
|
||||||
|
public boolean matchCharacter(char ch)
|
||||||
|
{
|
||||||
|
return (ch=='\'');
|
||||||
|
|
||||||
|
} // end matchCharacter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a character string, returns the total number of characters in that string, starting from the beginning,
|
||||||
|
* that are <I>not</I> handled by this filter before one that <I>is</I> appears. If none of the characters in this
|
||||||
|
* string are handled by the filter, the length of the string is returned.
|
||||||
|
*
|
||||||
|
* @param s The string to scan through.
|
||||||
|
* @return The length of the initial sequence of non-matching characters in this string.
|
||||||
|
*/
|
||||||
|
public int lengthNoMatch(String s)
|
||||||
|
{
|
||||||
|
int rc = s.indexOf('\'');
|
||||||
|
if (rc<0)
|
||||||
|
rc = s.length();
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
} // end lengthNoMatch
|
||||||
|
|
||||||
|
} // end class EncodeSQL
|
|
@ -0,0 +1,280 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
import com.silverwrist.dynamo.Namespaces;
|
||||||
|
import com.silverwrist.dynamo.except.*;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
class FrozenProfileObject
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final String NAMESPACE = Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE;
|
||||||
|
|
||||||
|
private static final Short DEFAULT_WORDWRAP = new Short((short)0);
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private ProfileObject m_profile; // backreference
|
||||||
|
private boolean m_rewrap_lines; // re-word-wrap lines?
|
||||||
|
private boolean m_process_angles; // process angle-bracketed strings?
|
||||||
|
private boolean m_process_parens; // process parenthesized strings?
|
||||||
|
private boolean m_process_brackets; // process bracketed strings?
|
||||||
|
private boolean m_process_braces; // process braced strings?
|
||||||
|
private boolean m_discard_html_tags; // discard all HTML tags?
|
||||||
|
private boolean m_discard_rejected_html; // discard HTML tags that are rejected?
|
||||||
|
private boolean m_discard_html_comments; // discard HTML comments?
|
||||||
|
private boolean m_discard_xml_constructs; // discard XML constructs (namespaced tags)?
|
||||||
|
private short m_word_wrap_length; // word wrap length
|
||||||
|
private HTMLOutputFilter[] m_output_filters; // the output filters
|
||||||
|
private HTMLOutputFilter[] m_raw_output_filters; // the raw output filters
|
||||||
|
private HTMLRewriter[] m_string_rewriters; // the string rewriters
|
||||||
|
private HTMLRewriter[] m_word_rewriters; // the word rewriters
|
||||||
|
private HTMLRewriter[] m_tag_rewriters; // the tag rewriters
|
||||||
|
private HTMLRewriter[] m_paren_rewriters; // the parenthesis rewriters
|
||||||
|
private HTMLRewriter[] m_bracket_rewriters; // the bracket rewriters
|
||||||
|
private HTMLRewriter[] m_brace_rewriters; // the brace rewriters
|
||||||
|
private BitSet m_allowed_tag_set; // the allowed tag set
|
||||||
|
private String m_openers; // the set of recognized "opener" characters
|
||||||
|
private Hashtable m_attrs_cache = new Hashtable(); // cached attributes from the underlying profile
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
FrozenProfileObject(ProfileObject prof) throws DatabaseException
|
||||||
|
{
|
||||||
|
m_profile = prof;
|
||||||
|
m_rewrap_lines =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"rewrap.lines",Boolean.FALSE))).booleanValue();
|
||||||
|
m_process_angles =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"process.angles",Boolean.TRUE))).booleanValue();
|
||||||
|
m_process_parens =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"process.parens",Boolean.TRUE))).booleanValue();
|
||||||
|
m_process_brackets =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"process.brackets",Boolean.FALSE))).booleanValue();
|
||||||
|
m_process_braces =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"process.braces",Boolean.FALSE))).booleanValue();
|
||||||
|
m_discard_html_tags =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"discard.html",Boolean.FALSE))).booleanValue();
|
||||||
|
m_discard_rejected_html =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"discard.html.rejected",
|
||||||
|
Boolean.FALSE))).booleanValue();
|
||||||
|
m_discard_html_comments =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"discard.html.comments",
|
||||||
|
Boolean.FALSE))).booleanValue();
|
||||||
|
m_discard_xml_constructs =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"discard.xml",Boolean.FALSE))).booleanValue();
|
||||||
|
m_word_wrap_length =
|
||||||
|
((Short)(PropertyUtils.getPropertyDefault(prof,NAMESPACE,"word.wrap",DEFAULT_WORDWRAP))).shortValue();
|
||||||
|
if (m_word_wrap_length<0)
|
||||||
|
m_word_wrap_length = 0;
|
||||||
|
m_output_filters = prof.getOutputFilters();
|
||||||
|
m_raw_output_filters = prof.getRawOutputFilters();
|
||||||
|
m_string_rewriters = prof.getStringRewriters();
|
||||||
|
m_word_rewriters = prof.getWordRewriters();
|
||||||
|
m_tag_rewriters = prof.getTagRewriters();
|
||||||
|
m_paren_rewriters = prof.getParenRewriters();
|
||||||
|
m_bracket_rewriters = prof.getBracketRewriters();
|
||||||
|
m_brace_rewriters = prof.getBraceRewriters();
|
||||||
|
|
||||||
|
// Compute the allowed tag set.
|
||||||
|
Set set1 = prof.getAllowedTagSet();
|
||||||
|
m_allowed_tag_set = new BitSet(HTMLTagSet._LAST.getValue());
|
||||||
|
Iterator it = set1.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{ // convert the set of objects into a set of bits
|
||||||
|
HTMLTagSet ts = (HTMLTagSet)(it.next());
|
||||||
|
m_allowed_tag_set.set(ts.getValue()-1);
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
// Construct the string full of "opener" characters.
|
||||||
|
StringBuffer buf = new StringBuffer(4);
|
||||||
|
if (m_process_angles)
|
||||||
|
buf.append('<');
|
||||||
|
if (m_process_parens)
|
||||||
|
buf.append('(');
|
||||||
|
if (m_process_brackets)
|
||||||
|
buf.append('[');
|
||||||
|
if (m_process_braces)
|
||||||
|
buf.append('{');
|
||||||
|
m_openers = buf.toString();
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean getRewrapLines()
|
||||||
|
{
|
||||||
|
return m_rewrap_lines;
|
||||||
|
|
||||||
|
} // end getRewrapLines
|
||||||
|
|
||||||
|
boolean getProcessAngles()
|
||||||
|
{
|
||||||
|
return m_process_angles;
|
||||||
|
|
||||||
|
} // end getProcessAngles
|
||||||
|
|
||||||
|
boolean getProcessParens()
|
||||||
|
{
|
||||||
|
return m_process_parens;
|
||||||
|
|
||||||
|
} // end getProcessParens
|
||||||
|
|
||||||
|
boolean getProcessBrackets()
|
||||||
|
{
|
||||||
|
return m_process_brackets;
|
||||||
|
|
||||||
|
} // end getProcessBrackets
|
||||||
|
|
||||||
|
boolean getProcessBraces()
|
||||||
|
{
|
||||||
|
return m_process_braces;
|
||||||
|
|
||||||
|
} // end getProcessBraces
|
||||||
|
|
||||||
|
boolean getDiscardHTMLTags()
|
||||||
|
{
|
||||||
|
return m_discard_html_tags;
|
||||||
|
|
||||||
|
} // end getDiscardHTMLTags
|
||||||
|
|
||||||
|
boolean getDiscardRejectedHTML()
|
||||||
|
{
|
||||||
|
return m_discard_rejected_html;
|
||||||
|
|
||||||
|
} // end getDiscardRejectedHTML
|
||||||
|
|
||||||
|
boolean getDiscardHTMLComments()
|
||||||
|
{
|
||||||
|
return m_discard_html_comments;
|
||||||
|
|
||||||
|
} // end getDiscardHTMLComments
|
||||||
|
|
||||||
|
boolean getDiscardXMLConstructs()
|
||||||
|
{
|
||||||
|
return m_discard_xml_constructs;
|
||||||
|
|
||||||
|
} // end getDiscardXMLConstructs
|
||||||
|
|
||||||
|
short getWordWrapLength()
|
||||||
|
{
|
||||||
|
return m_word_wrap_length;
|
||||||
|
|
||||||
|
} // end getWordWrapLength
|
||||||
|
|
||||||
|
HTMLOutputFilter[] getOutputFilters()
|
||||||
|
{
|
||||||
|
return m_output_filters;
|
||||||
|
|
||||||
|
} // end getOutputFilters
|
||||||
|
|
||||||
|
HTMLOutputFilter[] getRawOutputFilters()
|
||||||
|
{
|
||||||
|
return m_raw_output_filters;
|
||||||
|
|
||||||
|
} // end getOutputFilters
|
||||||
|
|
||||||
|
HTMLRewriter[] getStringRewriters()
|
||||||
|
{
|
||||||
|
return m_string_rewriters;
|
||||||
|
|
||||||
|
} // end getStringRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getWordRewriters()
|
||||||
|
{
|
||||||
|
return m_word_rewriters;
|
||||||
|
|
||||||
|
} // end getWordRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getTagRewriters()
|
||||||
|
{
|
||||||
|
return m_tag_rewriters;
|
||||||
|
|
||||||
|
} // end getTagRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getParenRewriters()
|
||||||
|
{
|
||||||
|
return m_paren_rewriters;
|
||||||
|
|
||||||
|
} // end getParenRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getBracketRewriters()
|
||||||
|
{
|
||||||
|
return m_bracket_rewriters;
|
||||||
|
|
||||||
|
} // end getBracketRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getBraceRewriters()
|
||||||
|
{
|
||||||
|
return m_brace_rewriters;
|
||||||
|
|
||||||
|
} // end getBraceRewriters
|
||||||
|
|
||||||
|
BitSet getAllowedTagSet()
|
||||||
|
{
|
||||||
|
return m_allowed_tag_set;
|
||||||
|
|
||||||
|
} // end getAllowedTagSet
|
||||||
|
|
||||||
|
String getOpeners()
|
||||||
|
{
|
||||||
|
return m_openers;
|
||||||
|
|
||||||
|
} // end getOpeners
|
||||||
|
|
||||||
|
boolean isAllowed(HTMLTagSet ts)
|
||||||
|
{
|
||||||
|
return m_allowed_tag_set.get(ts.getValue()-1);
|
||||||
|
|
||||||
|
} // end isAllowed
|
||||||
|
|
||||||
|
String getAttribute(String namespace, String name)
|
||||||
|
{
|
||||||
|
QualifiedNameKey key = new QualifiedNameKey(namespace,name);
|
||||||
|
String rc = (String)(m_attrs_cache.get(key));
|
||||||
|
if (rc!=null)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
Object tmp = PropertyUtils.getPropertyNoErr(m_profile,namespace,name);
|
||||||
|
if (tmp==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
rc = tmp.toString();
|
||||||
|
m_attrs_cache.put(key,rc);
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
} // end getAttribute
|
||||||
|
|
||||||
|
} // end class FrozenProfileObject
|
|
@ -0,0 +1,224 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import org.apache.commons.collections.*;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.w3c.dom.*;
|
||||||
|
import com.silverwrist.util.xml.*;
|
||||||
|
import com.silverwrist.dynamo.db.NamespaceCache;
|
||||||
|
import com.silverwrist.dynamo.except.*;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
public class HTMLCheckerManager
|
||||||
|
implements NamedObject, ComponentInitialize, ComponentShutdown, HTMLCheckerService, HTMLCheckerConfigRegister
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static Logger logger = Logger.getLogger(HTMLCheckerManager.class);
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String m_name; // name of this object
|
||||||
|
private ProfileOps m_ops; // profile operations
|
||||||
|
private NamespaceCache m_ns_cache; // namespace cache object
|
||||||
|
private ComponentShutdown m_hook_rt; // hook runtime services
|
||||||
|
private ComponentShutdown m_hook_init; // hook initialization services
|
||||||
|
private Vector m_configurators; // registered configurators
|
||||||
|
private ReferenceMap m_profiles; // profile map
|
||||||
|
private ReferenceMap m_frozen_profiles; // frozen profile map
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public HTMLCheckerManager()
|
||||||
|
{
|
||||||
|
m_configurators = new Vector();
|
||||||
|
m_profiles = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
|
||||||
|
m_frozen_profiles = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
|
||||||
|
m_configurators.add(new EncodeHTML());
|
||||||
|
m_configurators.add(new EncodeSQL());
|
||||||
|
m_configurators.add(new RewriteEMailAddresses());
|
||||||
|
m_configurators.add(new RewriteURLs());
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface NamedObject
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
|
||||||
|
} // end getName
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface ComponentInitialize
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the component.
|
||||||
|
*
|
||||||
|
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||||
|
* particular component. This is to be considered "read-only" by the component.
|
||||||
|
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||||
|
* which provides initialization services to the component. This will include an implementation
|
||||||
|
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||||
|
* get information about other objects previously initialized by the application.
|
||||||
|
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||||
|
* configuration.
|
||||||
|
*/
|
||||||
|
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||||
|
{
|
||||||
|
logger.info("HTMLCheckerManager initializing");
|
||||||
|
XMLLoader loader = XMLLoader.get();
|
||||||
|
String conn_name = null;
|
||||||
|
String nscache_name = null;
|
||||||
|
try
|
||||||
|
{ // verify the right node name
|
||||||
|
loader.verifyNodeName(config_root,"object");
|
||||||
|
|
||||||
|
// get the object's name
|
||||||
|
m_name = loader.getAttribute(config_root,"name");
|
||||||
|
|
||||||
|
// get the database configuration connection
|
||||||
|
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||||
|
Element elt = loader.getSubElement(config_root_h,"database");
|
||||||
|
conn_name = loader.getAttribute(elt,"connection");
|
||||||
|
nscache_name = loader.getAttribute(elt,"namespaces");
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (XMLLoadException e)
|
||||||
|
{ // error loading XML config data
|
||||||
|
throw new ConfigException(e);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
// Get the database connection pool and namespace cache.
|
||||||
|
DBConnectionPool pool = GetObjectUtils.getDatabaseConnection(services,conn_name);
|
||||||
|
m_ns_cache =
|
||||||
|
(NamespaceCache)(GetObjectUtils.getDynamoComponent(services,NamespaceCache.class,nscache_name));
|
||||||
|
|
||||||
|
// Get the database operations object.
|
||||||
|
m_ops = ProfileOps.get(pool);
|
||||||
|
|
||||||
|
// Register ourselves with the runtime services.
|
||||||
|
SingletonServiceProvider ssp = new SingletonServiceProvider("HTMLCheckerManager",HTMLCheckerService.class,this);
|
||||||
|
HookServiceProviders hooker = (HookServiceProviders)(services.queryService(HookServiceProviders.class));
|
||||||
|
m_hook_rt = hooker.hookRuntimeServiceProvider(ssp);
|
||||||
|
|
||||||
|
// Register ourselves with the init services.
|
||||||
|
ssp = new SingletonServiceProvider("HTMLCheckerManager",HTMLCheckerConfigRegister.class,this);
|
||||||
|
m_hook_init = hooker.hookInitServiceProvider(ssp);
|
||||||
|
|
||||||
|
} // end initialize
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface ComponentShutdown
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void shutdown()
|
||||||
|
{
|
||||||
|
m_hook_rt.shutdown();
|
||||||
|
m_hook_rt = null;
|
||||||
|
m_hook_init.shutdown();
|
||||||
|
m_hook_init = null;
|
||||||
|
m_ns_cache = null;
|
||||||
|
m_ops.dispose();
|
||||||
|
m_ops = null;
|
||||||
|
m_frozen_profiles.clear();
|
||||||
|
m_profiles.clear();
|
||||||
|
m_configurators.clear();
|
||||||
|
|
||||||
|
} // end shutdown
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLCheckerService
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public HTMLChecker createHTMLChecker(String profile_namespace, String profile_name) throws DatabaseException
|
||||||
|
{
|
||||||
|
QualifiedNameKey key = new QualifiedNameKey(profile_namespace,profile_name);
|
||||||
|
|
||||||
|
FrozenProfileObject p = null;
|
||||||
|
synchronized (this)
|
||||||
|
{ // retrieve profile from the internal cache
|
||||||
|
p = (FrozenProfileObject)(m_frozen_profiles.get(key));
|
||||||
|
if (p==null)
|
||||||
|
{ // OK, look up the profile object
|
||||||
|
ProfileObject profile = (ProfileObject)(m_profiles.get(key));
|
||||||
|
if (profile==null)
|
||||||
|
{ // get the index of the profile from the database
|
||||||
|
int prof_ndx = m_ops.getProfileIndex(m_ns_cache.namespaceNameToId(profile_namespace),profile_name);
|
||||||
|
|
||||||
|
// create the profile object
|
||||||
|
profile = new ProfileObject(m_ops,m_ns_cache,prof_ndx);
|
||||||
|
|
||||||
|
// Now we have to let the configurator objects have their way with it.
|
||||||
|
Iterator it = m_configurators.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{ // run each configurator in turn
|
||||||
|
HTMLCheckerConfigurator conf = (HTMLCheckerConfigurator)(it.next());
|
||||||
|
conf.configure(profile);
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
m_profiles.put(key,profile);
|
||||||
|
|
||||||
|
} // end if (need to get profile)
|
||||||
|
|
||||||
|
// Freeze the profile.
|
||||||
|
p = new FrozenProfileObject(profile);
|
||||||
|
m_frozen_profiles.put(key,p);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
} // end synchronized block
|
||||||
|
|
||||||
|
return new CheckerObject(p);
|
||||||
|
|
||||||
|
} // end createHTMLChecker
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLCheckerConfigRegister
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public ComponentShutdown registerConfigurator(HTMLCheckerConfigurator cfg)
|
||||||
|
{
|
||||||
|
m_configurators.add(cfg);
|
||||||
|
return new ShutdownVectorRemove(m_configurators,cfg);
|
||||||
|
|
||||||
|
} // end registerConfigurator
|
||||||
|
|
||||||
|
} // end class HTMLCheckerManager
|
|
@ -0,0 +1,20 @@
|
||||||
|
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
# (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
# language governing rights and limitations under the License.
|
||||||
|
#
|
||||||
|
# The Original Code is the Venice Web Communities System.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
# Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# This file has been localized for the en_US locale
|
||||||
|
no.profile=The specified profile was not found.
|
||||||
|
property.serialize=The value of property "{0}" could not be serialized.
|
||||||
|
property.deserialize=The value of property "{0}" could not be deserialized.
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
public final class MarkupData
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String m_prefix;
|
||||||
|
private String m_opentag;
|
||||||
|
private String m_body;
|
||||||
|
private String m_closetag;
|
||||||
|
private String m_suffix;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public MarkupData(String prefix, String opentag, String body, String closetag, String suffix)
|
||||||
|
{
|
||||||
|
m_prefix = prefix;
|
||||||
|
m_opentag = opentag;
|
||||||
|
m_body = body;
|
||||||
|
m_closetag = closetag;
|
||||||
|
m_suffix = suffix;
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Public getters
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getPrefix()
|
||||||
|
{
|
||||||
|
return m_prefix;
|
||||||
|
|
||||||
|
} // end getPrefix
|
||||||
|
|
||||||
|
public String getOpenTag()
|
||||||
|
{
|
||||||
|
return m_opentag;
|
||||||
|
|
||||||
|
} // end getOpenTag
|
||||||
|
|
||||||
|
public String getBody()
|
||||||
|
{
|
||||||
|
return m_body;
|
||||||
|
|
||||||
|
} // end getBody
|
||||||
|
|
||||||
|
public String getCloseTag()
|
||||||
|
{
|
||||||
|
return m_closetag;
|
||||||
|
|
||||||
|
} // end getCloseTag
|
||||||
|
|
||||||
|
public String getSuffix()
|
||||||
|
{
|
||||||
|
return m_suffix;
|
||||||
|
|
||||||
|
} // end getSuffix
|
||||||
|
|
||||||
|
public int getTotalLength()
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
if (m_prefix!=null)
|
||||||
|
rc += m_prefix.length();
|
||||||
|
if (m_body!=null)
|
||||||
|
rc += m_body.length();
|
||||||
|
if (m_suffix!=null)
|
||||||
|
rc += m_suffix.length();
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
} // end getTotalLength
|
||||||
|
|
||||||
|
} // end class MarkupData
|
|
@ -0,0 +1,244 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import org.apache.commons.collections.*;
|
||||||
|
import com.silverwrist.dynamo.db.NamespaceCache;
|
||||||
|
import com.silverwrist.dynamo.except.*;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
class ProfileObject implements HTMLCheckerProfile
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final HTMLOutputFilter[] OF_NULL = new HTMLOutputFilter[0];
|
||||||
|
private static final HTMLRewriter[] R_NULL = new HTMLRewriter[0];
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private ProfileOps m_ops; // database operations object
|
||||||
|
private NamespaceCache m_ns_cache; // namespace cache object
|
||||||
|
private int m_index; // index of this profile
|
||||||
|
private ReferenceMap m_properties; // property cache
|
||||||
|
private Vector m_output_filters = null; // output filters
|
||||||
|
private Vector m_raw_output_filters = null; // raw output filters
|
||||||
|
private Vector m_string_rewriters = null; // string rewriters
|
||||||
|
private Vector m_word_rewriters = null; // word rewriters
|
||||||
|
private Vector m_tag_rewriters = null; // tag rewriters
|
||||||
|
private Vector m_paren_rewriters = null; // parenthesis rewriters
|
||||||
|
private Vector m_bracket_rewriters = null; // bracket rewriters
|
||||||
|
private Vector m_brace_rewriters = null; // brace rewriters
|
||||||
|
private Set m_allowed_tag_set = null; // allowed tag set
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
ProfileObject(ProfileOps ops, NamespaceCache nscache, int ndx)
|
||||||
|
{
|
||||||
|
m_ops = ops;
|
||||||
|
m_ns_cache = nscache;
|
||||||
|
m_index = ndx;
|
||||||
|
m_properties = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface ObjectProvider
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves an object from this <CODE>ObjectProvider</CODE>.
|
||||||
|
*
|
||||||
|
* @param namespace The namespace to interpret the name relative to.
|
||||||
|
* @param name The name of the object to be retrieved.
|
||||||
|
* @return The object reference specified.
|
||||||
|
*/
|
||||||
|
public Object getObject(String namespace, String name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{ // convert the namespace name to an ID here
|
||||||
|
PropertyKey key = new PropertyKey(m_ns_cache.namespaceNameToId(namespace),name);
|
||||||
|
Object rc = null;
|
||||||
|
synchronized (this)
|
||||||
|
{ // start by looking in the properties map
|
||||||
|
rc = m_properties.get(key);
|
||||||
|
if (rc==null)
|
||||||
|
{ // no use - need to try the database
|
||||||
|
rc = m_ops.getProperty(m_index,key);
|
||||||
|
if (rc!=null)
|
||||||
|
m_properties.put(key,rc);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
} // end synchronized block
|
||||||
|
|
||||||
|
if (rc==null)
|
||||||
|
throw new NoSuchObjectException(this.toString(),namespace,name);
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (DatabaseException e)
|
||||||
|
{ // translate into our NoSuchObjectException but retain the DatabaseException
|
||||||
|
throw new NoSuchObjectException(this.toString(),namespace,name,e);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
} // end getObject
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLCheckerProfile
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void addOutputFilter(HTMLOutputFilter filter)
|
||||||
|
{
|
||||||
|
if (m_output_filters==null)
|
||||||
|
m_output_filters = new Vector();
|
||||||
|
m_output_filters.add(filter);
|
||||||
|
|
||||||
|
} // end addOutputFilter
|
||||||
|
|
||||||
|
public void addRawOutputFilter(HTMLOutputFilter filter)
|
||||||
|
{
|
||||||
|
if (m_raw_output_filters==null)
|
||||||
|
m_raw_output_filters = new Vector();
|
||||||
|
m_raw_output_filters.add(filter);
|
||||||
|
|
||||||
|
} // end addRawOutputFilter
|
||||||
|
|
||||||
|
public void addStringRewriter(HTMLRewriter rewriter)
|
||||||
|
{
|
||||||
|
if (m_string_rewriters==null)
|
||||||
|
m_string_rewriters = new Vector();
|
||||||
|
m_string_rewriters.add(rewriter);
|
||||||
|
|
||||||
|
} // end addStringRewriter
|
||||||
|
|
||||||
|
public void addWordRewriter(HTMLRewriter rewriter)
|
||||||
|
{
|
||||||
|
if (m_word_rewriters==null)
|
||||||
|
m_word_rewriters = new Vector();
|
||||||
|
m_word_rewriters.add(rewriter);
|
||||||
|
|
||||||
|
} // end addWordRewriter
|
||||||
|
|
||||||
|
public void addTagRewriter(HTMLRewriter rewriter)
|
||||||
|
{
|
||||||
|
if (m_tag_rewriters==null)
|
||||||
|
m_tag_rewriters = new Vector();
|
||||||
|
m_tag_rewriters.add(rewriter);
|
||||||
|
|
||||||
|
} // end addTagRewriter
|
||||||
|
|
||||||
|
public void addParenRewriter(HTMLRewriter rewriter)
|
||||||
|
{
|
||||||
|
if (m_paren_rewriters==null)
|
||||||
|
m_paren_rewriters = new Vector();
|
||||||
|
m_paren_rewriters.add(rewriter);
|
||||||
|
|
||||||
|
} // end addParenRewriter
|
||||||
|
|
||||||
|
public void addBracketRewriter(HTMLRewriter rewriter)
|
||||||
|
{
|
||||||
|
if (m_bracket_rewriters==null)
|
||||||
|
m_bracket_rewriters = new Vector();
|
||||||
|
m_bracket_rewriters.add(rewriter);
|
||||||
|
|
||||||
|
} // end addBracketRewriter
|
||||||
|
|
||||||
|
public void addBraceRewriter(HTMLRewriter rewriter)
|
||||||
|
{
|
||||||
|
if (m_brace_rewriters==null)
|
||||||
|
m_brace_rewriters = new Vector();
|
||||||
|
m_brace_rewriters.add(rewriter);
|
||||||
|
|
||||||
|
} // end addBraceRewriter
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
HTMLOutputFilter[] getOutputFilters()
|
||||||
|
{
|
||||||
|
return (m_output_filters==null) ? OF_NULL : (HTMLOutputFilter[])(m_output_filters.toArray(OF_NULL));
|
||||||
|
|
||||||
|
} // end getOutputFilters
|
||||||
|
|
||||||
|
HTMLOutputFilter[] getRawOutputFilters()
|
||||||
|
{
|
||||||
|
return (m_raw_output_filters==null) ? OF_NULL : (HTMLOutputFilter[])(m_raw_output_filters.toArray(OF_NULL));
|
||||||
|
|
||||||
|
} // end getOutputFilters
|
||||||
|
|
||||||
|
HTMLRewriter[] getStringRewriters()
|
||||||
|
{
|
||||||
|
return (m_string_rewriters==null) ? R_NULL : (HTMLRewriter[])(m_string_rewriters.toArray(R_NULL));
|
||||||
|
|
||||||
|
} // end getStringRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getWordRewriters()
|
||||||
|
{
|
||||||
|
return (m_word_rewriters==null) ? R_NULL : (HTMLRewriter[])(m_word_rewriters.toArray(R_NULL));
|
||||||
|
|
||||||
|
} // end getWordRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getTagRewriters()
|
||||||
|
{
|
||||||
|
return (m_tag_rewriters==null) ? R_NULL : (HTMLRewriter[])(m_tag_rewriters.toArray(R_NULL));
|
||||||
|
|
||||||
|
} // end getTagRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getParenRewriters()
|
||||||
|
{
|
||||||
|
return (m_paren_rewriters==null) ? R_NULL : (HTMLRewriter[])(m_paren_rewriters.toArray(R_NULL));
|
||||||
|
|
||||||
|
} // end getParenRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getBracketRewriters()
|
||||||
|
{
|
||||||
|
return (m_bracket_rewriters==null) ? R_NULL : (HTMLRewriter[])(m_bracket_rewriters.toArray(R_NULL));
|
||||||
|
|
||||||
|
} // end getBracketRewriters
|
||||||
|
|
||||||
|
HTMLRewriter[] getBraceRewriters()
|
||||||
|
{
|
||||||
|
return (m_brace_rewriters==null) ? R_NULL : (HTMLRewriter[])(m_brace_rewriters.toArray(R_NULL));
|
||||||
|
|
||||||
|
} // end getBraceRewriters
|
||||||
|
|
||||||
|
Set getAllowedTagSet() throws DatabaseException
|
||||||
|
{
|
||||||
|
if (m_allowed_tag_set==null)
|
||||||
|
m_allowed_tag_set = m_ops.getAllowedTagSet(m_index);
|
||||||
|
return m_allowed_tag_set;
|
||||||
|
|
||||||
|
} // end getAllowedTagSet
|
||||||
|
|
||||||
|
} // end class ProfileObject
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import com.silverwrist.dynamo.db.OpsBase;
|
||||||
|
import com.silverwrist.dynamo.except.*;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
abstract class ProfileOps extends OpsBase
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected ProfileOps(DBConnectionPool pool)
|
||||||
|
{
|
||||||
|
super(pool);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Abstract operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract int getProfileIndex(int nsid, String name) throws DatabaseException;
|
||||||
|
|
||||||
|
abstract Object getProperty(int profid, PropertyKey key) throws DatabaseException;
|
||||||
|
|
||||||
|
abstract Set getAllowedTagSet(int profid) throws DatabaseException;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External static operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static ProfileOps get(DBConnectionPool pool) throws ConfigException
|
||||||
|
{
|
||||||
|
return (ProfileOps)get(pool,ProfileOps.class.getClassLoader(),ProfileOps.class.getName() + "_","ProfileOps");
|
||||||
|
|
||||||
|
} // end get
|
||||||
|
|
||||||
|
} // end class ProfileOps
|
|
@ -0,0 +1,190 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
|
import com.silverwrist.util.*;
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
import com.silverwrist.dynamo.except.*;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
public class ProfileOps_mysql extends ProfileOps
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private PropertySerializer m_psz;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public ProfileOps_mysql(DBConnectionPool pool)
|
||||||
|
{
|
||||||
|
super(pool);
|
||||||
|
m_psz = (PropertySerializer)(pool.queryService(PropertySerializer.class));
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Overrides from class OpsBase
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
m_psz = null;
|
||||||
|
super.dispose();
|
||||||
|
|
||||||
|
} // end dispose
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Abstract implementations from class ProfileOps
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
int getProfileIndex(int nsid, String name) throws DatabaseException
|
||||||
|
{
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try
|
||||||
|
{ // get a connection
|
||||||
|
conn = getConnection();
|
||||||
|
|
||||||
|
// prepare a statement to look up the profile index
|
||||||
|
stmt = conn.prepareStatement("SELECT profid FROM htmlprofiles WHERE nsid = ? AND name = ?;");
|
||||||
|
stmt.setInt(1,nsid);
|
||||||
|
stmt.setString(2,name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
return rs.getInt(1);
|
||||||
|
throw new DatabaseException(ProfileOps_mysql.class,"HTMLCheckerMessages","no.profile");
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (SQLException e)
|
||||||
|
{ // translate to a general DatabaseException
|
||||||
|
throw generalException(e);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
finally
|
||||||
|
{ // shut everything down
|
||||||
|
SQLUtils.shutdown(rs);
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
SQLUtils.shutdown(conn);
|
||||||
|
|
||||||
|
} // end finally
|
||||||
|
|
||||||
|
} // end getProfileIndex
|
||||||
|
|
||||||
|
Object getProperty(int profid, PropertyKey key) throws DatabaseException
|
||||||
|
{
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
String rc_str = null;
|
||||||
|
try
|
||||||
|
{ // get a connection
|
||||||
|
conn = getConnection();
|
||||||
|
|
||||||
|
// look up the property
|
||||||
|
stmt = conn.prepareStatement("SELECT prop_value FROM htmlprops WHERE profid = ? AND nsid = ? "
|
||||||
|
+ "AND prop_name = ?;");
|
||||||
|
stmt.setInt(1,profid);
|
||||||
|
stmt.setInt(2,key.getNamespaceID());
|
||||||
|
stmt.setString(3,key.getName());
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
if (!(rs.next()))
|
||||||
|
return null; // property not found
|
||||||
|
|
||||||
|
rc_str = rs.getString(1);
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (SQLException e)
|
||||||
|
{ // translate to a general DatabaseException
|
||||||
|
throw generalException(e);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
finally
|
||||||
|
{ // shut everything down
|
||||||
|
SQLUtils.shutdown(rs);
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
SQLUtils.shutdown(conn);
|
||||||
|
|
||||||
|
} // end finally
|
||||||
|
|
||||||
|
// Deserialize the property value.
|
||||||
|
Object rc = m_psz.deserializeProperty(rc_str);
|
||||||
|
if (rc!=null)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
// deserialization exception - throw it
|
||||||
|
DatabaseException de = new DatabaseException(ProfileOps_mysql.class,"HTMLCheckerMessages","property.deserialize");
|
||||||
|
de.setParameter(0,key.getName());
|
||||||
|
throw de;
|
||||||
|
|
||||||
|
} // end getProperty
|
||||||
|
|
||||||
|
Set getAllowedTagSet(int profid) throws DatabaseException
|
||||||
|
{
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try
|
||||||
|
{ // get a connection
|
||||||
|
conn = getConnection();
|
||||||
|
|
||||||
|
// create and execute the statement
|
||||||
|
stmt = conn.prepareStatement("SELECT tagset FROM htmltagsets WHERE profid = ?;");
|
||||||
|
stmt.setInt(1,profid);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
// prepare the return value
|
||||||
|
HashSet rc = new HashSet();
|
||||||
|
while (rs.next())
|
||||||
|
{ // convert strings to enum values and add them
|
||||||
|
HTMLTagSet ts = HTMLTagSet.getEnum(rs.getString(1));
|
||||||
|
if (ts!=null)
|
||||||
|
rc.add(ts);
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (SQLException e)
|
||||||
|
{ // translate to a general DatabaseException
|
||||||
|
throw generalException(e);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
finally
|
||||||
|
{ // shut everything down
|
||||||
|
SQLUtils.shutdown(rs);
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
SQLUtils.shutdown(conn);
|
||||||
|
|
||||||
|
} // end finally
|
||||||
|
|
||||||
|
} // end getAllowedTagSet
|
||||||
|
|
||||||
|
} // end class ProfileOps_mysql
|
|
@ -0,0 +1,123 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import java.util.regex.*;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import com.silverwrist.dynamo.Namespaces;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
class RewriteEMailAddresses implements HTMLCheckerConfigurator, HTMLRewriter
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static Logger logger = Logger.getLogger(RewriteEMailAddresses.class);
|
||||||
|
|
||||||
|
private static final String DEFAULT_TARGET = "Wander";
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Pattern m_email_pattern;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
RewriteEMailAddresses()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{ // pre-compile all our regex patterns
|
||||||
|
m_email_pattern = Pattern.compile("^[A-Za-z0-9!#$%*+-/=?^_`{|}~.]+@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*$");
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (PatternSyntaxException pe)
|
||||||
|
{ // log an error, all we can do
|
||||||
|
logger.fatal("Pattern compilation error in RewriteEMailAddresses",pe);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLCheckerConfigurator
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void configure(HTMLCheckerProfile profile)
|
||||||
|
{
|
||||||
|
boolean enable =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.email.string",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addStringRewriter(this);
|
||||||
|
enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.email.tag",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addTagRewriter(this);
|
||||||
|
enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.email.paren",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addParenRewriter(this);
|
||||||
|
enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.email.bracket",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addBracketRewriter(this);
|
||||||
|
enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.email.brace",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addBraceRewriter(this);
|
||||||
|
|
||||||
|
} // end configure
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLRewriter
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public QualifiedNameKey getName()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} // end getName
|
||||||
|
|
||||||
|
public MarkupData rewrite(String data, String prefix, String suffix, HTMLRewriterSite site)
|
||||||
|
{
|
||||||
|
if (!(m_email_pattern.matcher(data).matches()))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// build the <A> tag (the gnarliest part)
|
||||||
|
StringBuffer buf = new StringBuffer("<a href=\"mailto:");
|
||||||
|
buf.append(data).append("\" target=\"");
|
||||||
|
String target = site.getAttribute(Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,"default.A.target");
|
||||||
|
if (target==null)
|
||||||
|
target = DEFAULT_TARGET;
|
||||||
|
buf.append(target).append("\">");
|
||||||
|
|
||||||
|
return new MarkupData(prefix,buf.toString(),data,"</a>",suffix);
|
||||||
|
|
||||||
|
} // end rewrite
|
||||||
|
|
||||||
|
} // end class RewriteEMailAddresses
|
|
@ -0,0 +1,227 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.*;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import com.silverwrist.dynamo.Namespaces;
|
||||||
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
|
class RewriteURLs implements HTMLCheckerConfigurator, HTMLRewriter
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Internal class that contains matching information
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static class Match
|
||||||
|
{
|
||||||
|
/*====================================================================
|
||||||
|
* Attributes
|
||||||
|
*====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Pattern m_pat;
|
||||||
|
private String m_prefix;
|
||||||
|
|
||||||
|
/*====================================================================
|
||||||
|
* Constructors
|
||||||
|
*====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
Match(String pattern) throws PatternSyntaxException
|
||||||
|
{
|
||||||
|
m_pat = Pattern.compile(pattern);
|
||||||
|
m_prefix = null;
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
Match(String pattern, String prefix) throws PatternSyntaxException
|
||||||
|
{
|
||||||
|
m_pat = Pattern.compile(pattern);
|
||||||
|
m_prefix = prefix;
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*====================================================================
|
||||||
|
* External operations
|
||||||
|
*====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean match(String input)
|
||||||
|
{
|
||||||
|
return m_pat.matcher(input).matches();
|
||||||
|
|
||||||
|
} // end match
|
||||||
|
|
||||||
|
String prefixate(String input)
|
||||||
|
{
|
||||||
|
if (m_prefix==null)
|
||||||
|
return input;
|
||||||
|
else
|
||||||
|
return m_prefix + input;
|
||||||
|
|
||||||
|
} // end prefixate
|
||||||
|
|
||||||
|
} // end class Match
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static Logger logger = Logger.getLogger(RewriteURLs.class);
|
||||||
|
|
||||||
|
private static final String DEFAULT_TARGET = "Wander";
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private List m_matchers;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
RewriteURLs()
|
||||||
|
{
|
||||||
|
ArrayList l = new ArrayList();
|
||||||
|
try
|
||||||
|
{ // pre-compile all our regex patterns
|
||||||
|
// recognize: http://<host>[:<port>]...
|
||||||
|
l.add(new Match("^http://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?(/.*)?"));
|
||||||
|
|
||||||
|
// recognize: ftp://<host>[:<port>]...
|
||||||
|
l.add(new Match("^ftp://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?(/.*)?"));
|
||||||
|
|
||||||
|
// recognize: gopher://<host>[:<port>]...
|
||||||
|
l.add(new Match("^gopher://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?(/.*)?"));
|
||||||
|
|
||||||
|
// recognize: mailto:<valid E-mail address>
|
||||||
|
l.add(new Match("^mailto:[A-Za-z0-9!#$%*+-/=?^_`{|}~.]+@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*"));
|
||||||
|
|
||||||
|
// recognize: news:<newsgroup name>
|
||||||
|
l.add(new Match("^news:[A-Za-z0-9-_]+(\\.[A-Za-z0-9-_]+)*$"));
|
||||||
|
|
||||||
|
// recognize: news:<message-id>
|
||||||
|
l.add(new Match("^news:.*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*$"));
|
||||||
|
|
||||||
|
// recognize: nntp://<host>[:<port>]/<newsgroup>/<article>
|
||||||
|
l.add(new
|
||||||
|
Match("^nntp://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?/[A-Za-z0-9-_]+(\\.[A-Za-z0-9-_]+)*/[0-9]+$"));
|
||||||
|
|
||||||
|
// recognize: telnet://<host>[:<port>]
|
||||||
|
l.add(new Match("^telnet://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?$"));
|
||||||
|
|
||||||
|
// recognize: tn3270://<host>[:<port>]
|
||||||
|
l.add(new Match("^tn3270://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?$"));
|
||||||
|
|
||||||
|
// recognize "www.whatever" and tack http:// onto the front
|
||||||
|
l.add(new Match("^www\\.[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(/.*)?","http://"));
|
||||||
|
|
||||||
|
// recognize "ftp.whatever" and tack ftp:// onto the front
|
||||||
|
l.add(new Match("^ftp\\.[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(/.*)?","ftp://"));
|
||||||
|
|
||||||
|
// recognize "gopher.whatever" and tack gopher:// onto the front
|
||||||
|
l.add(new Match("^gopher\\.[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(/.*)?","gopher://"));
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (PatternSyntaxException pe)
|
||||||
|
{ // log an error, all we can do
|
||||||
|
logger.fatal("Pattern compilation error in RewriteEMailAddresses",pe);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
l.trimToSize();
|
||||||
|
m_matchers = Collections.unmodifiableList(l);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLCheckerConfigurator
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void configure(HTMLCheckerProfile profile)
|
||||||
|
{
|
||||||
|
boolean enable =
|
||||||
|
((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.URL.string",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addStringRewriter(this);
|
||||||
|
enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.URL.tag",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addTagRewriter(this);
|
||||||
|
enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.URL.paren",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addParenRewriter(this);
|
||||||
|
enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.URL.bracket",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addBracketRewriter(this);
|
||||||
|
enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,
|
||||||
|
"rewrite.URL.brace",Boolean.FALSE))).booleanValue();
|
||||||
|
if (enable)
|
||||||
|
profile.addBraceRewriter(this);
|
||||||
|
|
||||||
|
} // end configure
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface HTMLRewriter
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public QualifiedNameKey getName()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} // end getName
|
||||||
|
|
||||||
|
public MarkupData rewrite(String data, String prefix, String suffix, HTMLRewriterSite site)
|
||||||
|
{
|
||||||
|
Iterator it = m_matchers.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{ // look for a matching element
|
||||||
|
Match x = (Match)(it.next());
|
||||||
|
if (x.match(data))
|
||||||
|
{ // found it! build the <A> tag for the markup
|
||||||
|
StringBuffer buf = new StringBuffer("<a href=\"");
|
||||||
|
buf.append(x.prefixate(data)).append("\" target=\"");
|
||||||
|
String target = site.getAttribute(Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,"default.A.target");
|
||||||
|
if (target==null)
|
||||||
|
target = DEFAULT_TARGET;
|
||||||
|
buf.append(target).append("\">");
|
||||||
|
|
||||||
|
return new MarkupData(prefix,buf.toString(),data,"</a>",suffix);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
return null; // punt
|
||||||
|
|
||||||
|
} // end rewrite
|
||||||
|
|
||||||
|
} // end class RewriteURLs
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import java.util.regex.*;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
import com.silverwrist.dynamo.Namespaces;
|
||||||
|
|
||||||
|
class A_Tag extends BalancedTag
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static Logger logger = Logger.getLogger(A_Tag.class);
|
||||||
|
|
||||||
|
private static final String DEFAULT_TARGET = "Wander";
|
||||||
|
|
||||||
|
private static Pattern TARGET_PATTERN;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
A_Tag()
|
||||||
|
{
|
||||||
|
super("A",false,HTMLTagSet.ANCHOR);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Overrides from class HTMLTag
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String rewrite(String tag_data, boolean is_closing, HTMLTagSite site)
|
||||||
|
{
|
||||||
|
if (is_closing)
|
||||||
|
return tag_data;
|
||||||
|
if (TARGET_PATTERN.matcher(tag_data).matches())
|
||||||
|
return tag_data;
|
||||||
|
String target_window = site.getAttribute(Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,"default.A.target");
|
||||||
|
if (target_window==null)
|
||||||
|
target_window = DEFAULT_TARGET;
|
||||||
|
return tag_data + " target=\"" + target_window + "\"";
|
||||||
|
|
||||||
|
} // end rewrite
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static initializer
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{ // pre-compile all our regex patterns
|
||||||
|
TARGET_PATTERN = Pattern.compile("\\s+target\\s*=\\s*([\"']?)\\w+\\1(?:\\s+.*)?$",Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (PatternSyntaxException pe)
|
||||||
|
{ // log an error, all we can do
|
||||||
|
logger.fatal("Pattern compilation error in A_Tag",pe);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
} // end static initializer
|
||||||
|
|
||||||
|
} // end class A_Tag
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
|
||||||
|
class BalancedTag extends OpenCloseTag
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
BalancedTag(String tagname, boolean linebreak, HTMLTagSet set)
|
||||||
|
{
|
||||||
|
super(tagname,linebreak,set);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public final boolean balanceTags()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} // end balanceTags
|
||||||
|
|
||||||
|
} // end class BalancedTag
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
|
||||||
|
public class HTMLTag
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String m_tagname;
|
||||||
|
private boolean m_linebreak;
|
||||||
|
private HTMLTagSet m_set;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
HTMLTag(String tagname, boolean linebreak, HTMLTagSet set)
|
||||||
|
{
|
||||||
|
m_tagname = tagname;
|
||||||
|
m_linebreak = linebreak;
|
||||||
|
m_set = set;
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Overrides from class Object
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if (!(obj instanceof HTMLTag))
|
||||||
|
return false;
|
||||||
|
HTMLTag other = (HTMLTag)obj;
|
||||||
|
return m_tagname.equals(other.m_tagname);
|
||||||
|
|
||||||
|
} // end equals
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return m_tagname.hashCode();
|
||||||
|
|
||||||
|
} // end hashCode
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "<" + m_tagname + ">";
|
||||||
|
|
||||||
|
} // end toString
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getTagName()
|
||||||
|
{
|
||||||
|
return m_tagname;
|
||||||
|
|
||||||
|
} // end getTagName
|
||||||
|
|
||||||
|
public boolean allowClose()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} // end allowClose
|
||||||
|
|
||||||
|
public boolean balanceTags()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} // end balanceTags
|
||||||
|
|
||||||
|
public boolean causeLineBreak(boolean is_closing)
|
||||||
|
{
|
||||||
|
return m_linebreak;
|
||||||
|
|
||||||
|
} // end causeLineBreak
|
||||||
|
|
||||||
|
public String makeClosingTag()
|
||||||
|
{
|
||||||
|
throw new RuntimeException("cannot make closing tags of basic HTMLTag");
|
||||||
|
|
||||||
|
} // end makeClosingTag
|
||||||
|
|
||||||
|
public HTMLTagSet getTagSet()
|
||||||
|
{
|
||||||
|
return m_set;
|
||||||
|
|
||||||
|
} // end getTagSet
|
||||||
|
|
||||||
|
public String rewrite(String tag_data, boolean is_closing, HTMLTagSite site)
|
||||||
|
{
|
||||||
|
return tag_data;
|
||||||
|
|
||||||
|
} // end rewrite
|
||||||
|
|
||||||
|
} // end class HTMLTag
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.iface.ObjectProvider;
|
||||||
|
|
||||||
|
public interface HTMLTagSite extends ObjectProvider
|
||||||
|
{
|
||||||
|
public String getAttribute(String namespace, String name);
|
||||||
|
|
||||||
|
public void controlMessage(String message, Object data);
|
||||||
|
|
||||||
|
} // end interface HTMLTagSite
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
|
||||||
|
class ListElementTag extends OpenCloseTag
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
ListElementTag(String tagname, HTMLTagSet set)
|
||||||
|
{
|
||||||
|
super(tagname,true,set);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public boolean causeLineBreak(boolean is_closing)
|
||||||
|
{
|
||||||
|
return !is_closing;
|
||||||
|
|
||||||
|
} // end causeLineBreak
|
||||||
|
|
||||||
|
} // end class ListElementTag
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
|
||||||
|
class NOBR_Tag extends BalancedTag
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
NOBR_Tag()
|
||||||
|
{
|
||||||
|
super("NOBR",false,HTMLTagSet.BLOCK);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Overrides from class HTMLTag
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String rewrite(String tag_data, boolean is_closing, HTMLTagSite site)
|
||||||
|
{
|
||||||
|
if (is_closing)
|
||||||
|
site.controlMessage("/NOBR",null);
|
||||||
|
else
|
||||||
|
site.controlMessage("NOBR",null);
|
||||||
|
return super.rewrite(tag_data,is_closing,site);
|
||||||
|
|
||||||
|
} // end rewrite
|
||||||
|
|
||||||
|
} // end class NOBR_Tag
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
|
||||||
|
class OpenCloseTag extends HTMLTag
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
OpenCloseTag(String tagname, boolean linebreak, HTMLTagSet set)
|
||||||
|
{
|
||||||
|
super(tagname,linebreak,set);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public final boolean allowClose()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} // end allowClose
|
||||||
|
|
||||||
|
public final String makeClosingTag()
|
||||||
|
{
|
||||||
|
return "</" + getTagName() + ">";
|
||||||
|
|
||||||
|
} // end makeClosingTag
|
||||||
|
|
||||||
|
} // end class OpenCloseTag
|
|
@ -0,0 +1,215 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
|
||||||
|
public class TagsList
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static TagsList _self = null;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private HashMap m_tagname_to_object = new HashMap();
|
||||||
|
private int m_tag_maxlen = 0;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private TagsList()
|
||||||
|
{
|
||||||
|
install(new HTMLTag("!DOCTYPE",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new HTMLTag("%",false,HTMLTagSet.SERVER));
|
||||||
|
install(new HTMLTag("%!",false,HTMLTagSet.SERVER));
|
||||||
|
install(new HTMLTag("%=",false,HTMLTagSet.SERVER));
|
||||||
|
install(new HTMLTag("?",false,HTMLTagSet.SERVER));
|
||||||
|
install(new HTMLTag("?=",false,HTMLTagSet.SERVER));
|
||||||
|
install(new HTMLTag("?PHP",false,HTMLTagSet.SERVER));
|
||||||
|
install(new A_Tag());
|
||||||
|
install(new BalancedTag("ABBR",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("ACRONYM",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("ADDRESS",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new BalancedTag("APPLET",false,HTMLTagSet.ACTIVECONTENT));
|
||||||
|
install(new HTMLTag("AREA",false,HTMLTagSet.IMAGEMAP));
|
||||||
|
install(new BalancedTag("B",false,HTMLTagSet.INLINE));
|
||||||
|
install(new HTMLTag("BASE",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new HTMLTag("BASEFONT",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new BalancedTag("BDO",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("BEAN",false,HTMLTagSet.JAVASERVER));
|
||||||
|
install(new HTMLTag("BGSOUND",false,HTMLTagSet.MSFT_DOCUMENT));
|
||||||
|
install(new BalancedTag("BIG",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("BLINK",false,HTMLTagSet.NSCP_INLINE));
|
||||||
|
install(new BalancedTag("BLOCKQUOTE",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new OpenCloseTag("BODY",true,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new HTMLTag("BR",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new OpenCloseTag("BUTTON",false,HTMLTagSet.FORMS));
|
||||||
|
install(new BalancedTag("CAPTION",true,HTMLTagSet.TABLES));
|
||||||
|
install(new BalancedTag("CENTER",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new BalancedTag("CITE",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("CODE",false,HTMLTagSet.INLINE));
|
||||||
|
install(new HTMLTag("COL",true,HTMLTagSet.TABLES));
|
||||||
|
install(new OpenCloseTag("COLGROUP",true,HTMLTagSet.TABLES));
|
||||||
|
install(new BalancedTag("COMMENT",false,HTMLTagSet.MSFT_INLINE));
|
||||||
|
install(new ListElementTag("DD",HTMLTagSet.BLOCK));
|
||||||
|
install(new BalancedTag("DEL",false,HTMLTagSet.CHANGE));
|
||||||
|
install(new BalancedTag("DFN",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("DIR",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new BalancedTag("DIV",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new BalancedTag("DL",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new ListElementTag("DT",HTMLTagSet.BLOCK));
|
||||||
|
install(new BalancedTag("EM",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("EMBED",false,HTMLTagSet.ACTIVECONTENT));
|
||||||
|
install(new BalancedTag("FIELDSET",false,HTMLTagSet.FORMS));
|
||||||
|
install(new BalancedTag("FONT",false,HTMLTagSet.FONT));
|
||||||
|
install(new BalancedTag("FORM",false,HTMLTagSet.FORMS));
|
||||||
|
install(new HTMLTag("FRAME",true,HTMLTagSet.FRAMES));
|
||||||
|
install(new BalancedTag("FRAMESET",false,HTMLTagSet.FRAMES));
|
||||||
|
install(new BalancedTag("H1",true,HTMLTagSet.FONT));
|
||||||
|
install(new BalancedTag("H2",true,HTMLTagSet.FONT));
|
||||||
|
install(new BalancedTag("H3",true,HTMLTagSet.FONT));
|
||||||
|
install(new BalancedTag("H4",true,HTMLTagSet.FONT));
|
||||||
|
install(new BalancedTag("H5",true,HTMLTagSet.FONT));
|
||||||
|
install(new BalancedTag("H6",true,HTMLTagSet.FONT));
|
||||||
|
install(new OpenCloseTag("HEAD",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new HTMLTag("HR",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new OpenCloseTag("HTML",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new BalancedTag("I",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("IFRAME",true,HTMLTagSet.FRAMES));
|
||||||
|
install(new BalancedTag("ILAYER",true,HTMLTagSet.NSCP_LAYERS));
|
||||||
|
install(new HTMLTag("IMG",false,HTMLTagSet.IMAGES));
|
||||||
|
install(new HTMLTag("INPUT",false,HTMLTagSet.FORMS));
|
||||||
|
install(new BalancedTag("INS",false,HTMLTagSet.CHANGE));
|
||||||
|
install(new HTMLTag("ISINDEX",false,HTMLTagSet.FORMS));
|
||||||
|
install(new BalancedTag("KBD",false,HTMLTagSet.INLINE));
|
||||||
|
install(new HTMLTag("KEYGEN",false,HTMLTagSet.NSCP_FORMS));
|
||||||
|
install(new BalancedTag("LABEL",false,HTMLTagSet.FORMS));
|
||||||
|
install(new BalancedTag("LAYER",true,HTMLTagSet.NSCP_LAYERS));
|
||||||
|
install(new BalancedTag("LEGEND",false,HTMLTagSet.FORMS));
|
||||||
|
install(new ListElementTag("LI",HTMLTagSet.BLOCK));
|
||||||
|
install(new HTMLTag("LINK",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new BalancedTag("LISTING",false,HTMLTagSet.MSFT_INLINE));
|
||||||
|
install(new BalancedTag("MAP",false,HTMLTagSet.IMAGEMAP));
|
||||||
|
install(new BalancedTag("MARQUEE",true,HTMLTagSet.MSFT_BLOCK));
|
||||||
|
install(new BalancedTag("MENU",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new HTMLTag("META",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new BalancedTag("MULTICOL",true,HTMLTagSet.NSCP_BLOCK));
|
||||||
|
install(new NOBR_Tag());
|
||||||
|
install(new BalancedTag("NOEMBED",false,HTMLTagSet.ACTIVECONTENT));
|
||||||
|
install(new BalancedTag("NOFRAMES",false,HTMLTagSet.FRAMES));
|
||||||
|
install(new BalancedTag("NOLAYER",false,HTMLTagSet.NSCP_LAYERS));
|
||||||
|
install(new BalancedTag("NOSCRIPT",false,HTMLTagSet.ACTIVECONTENT));
|
||||||
|
install(new BalancedTag("OBJECT",false,HTMLTagSet.ACTIVECONTENT));
|
||||||
|
install(new BalancedTag("OL",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new BalancedTag("OPTGROUP",false,HTMLTagSet.FORMS));
|
||||||
|
install(new ListElementTag("OPTION",HTMLTagSet.FORMS));
|
||||||
|
install(new OpenCloseTag("P",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new HTMLTag("PARAM",false,HTMLTagSet.ACTIVECONTENT));
|
||||||
|
install(new HTMLTag("PLAINTEXT",false,HTMLTagSet.PREFORMAT));
|
||||||
|
install(new BalancedTag("PRE",false,HTMLTagSet.PREFORMAT));
|
||||||
|
install(new BalancedTag("Q",false,HTMLTagSet.INLINE));
|
||||||
|
install(new HTMLTag("RT",false,HTMLTagSet.MSFT_ACTIVECONTENT));
|
||||||
|
install(new BalancedTag("RUBY",false,HTMLTagSet.MSFT_ACTIVECONTENT));
|
||||||
|
install(new BalancedTag("S",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("SAMP",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("SCRIPT",false,HTMLTagSet.ACTIVECONTENT));
|
||||||
|
install(new BalancedTag("SELECT",false,HTMLTagSet.FORMS));
|
||||||
|
install(new BalancedTag("SERVER",false,HTMLTagSet.NSCP_SERVER));
|
||||||
|
install(new BalancedTag("SERVLET",false,HTMLTagSet.JAVASERVER));
|
||||||
|
install(new BalancedTag("SMALL",false,HTMLTagSet.INLINE));
|
||||||
|
install(new HTMLTag("SPACER",false,HTMLTagSet.NSCP_INLINE));
|
||||||
|
install(new BalancedTag("SPAN",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("STRIKE",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("STRONG",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("STYLE",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new BalancedTag("SUB",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("SUP",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("TABLE",true,HTMLTagSet.TABLES));
|
||||||
|
install(new OpenCloseTag("TBODY",false,HTMLTagSet.TABLES));
|
||||||
|
install(new BalancedTag("TD",true,HTMLTagSet.TABLES));
|
||||||
|
install(new BalancedTag("TEXTAREA",true,HTMLTagSet.FORMS));
|
||||||
|
install(new OpenCloseTag("TFOOT",false,HTMLTagSet.TABLES));
|
||||||
|
install(new BalancedTag("TH",true,HTMLTagSet.TABLES));
|
||||||
|
install(new OpenCloseTag("THEAD",false,HTMLTagSet.TABLES));
|
||||||
|
install(new BalancedTag("TITLE",false,HTMLTagSet.DOCUMENT));
|
||||||
|
install(new BalancedTag("TR",true,HTMLTagSet.TABLES));
|
||||||
|
install(new BalancedTag("TT",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("U",false,HTMLTagSet.INLINE));
|
||||||
|
install(new BalancedTag("UL",true,HTMLTagSet.BLOCK));
|
||||||
|
install(new BalancedTag("VAR",false,HTMLTagSet.INLINE));
|
||||||
|
install(new WBR_Tag());
|
||||||
|
install(new BalancedTag("XML",false,HTMLTagSet.MSFT_ACTIVECONTENT));
|
||||||
|
install(new BalancedTag("XMP",false,HTMLTagSet.NSCP_INLINE));
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Internal operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private final void install(HTMLTag tag)
|
||||||
|
{
|
||||||
|
m_tagname_to_object.put(tag.getTagName(),tag);
|
||||||
|
int len = tag.getTagName().length();
|
||||||
|
if (len>m_tag_maxlen)
|
||||||
|
m_tag_maxlen = len;
|
||||||
|
|
||||||
|
} // end install
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public int getMaxTagLength()
|
||||||
|
{
|
||||||
|
return m_tag_maxlen;
|
||||||
|
|
||||||
|
} // end getMaxTagLength
|
||||||
|
|
||||||
|
public HTMLTag getTag(String name)
|
||||||
|
{
|
||||||
|
return (HTMLTag)(m_tagname_to_object.get(name.toUpperCase()));
|
||||||
|
|
||||||
|
} // end getTag
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External static operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static synchronized TagsList get()
|
||||||
|
{
|
||||||
|
if (_self==null)
|
||||||
|
_self = new TagsList();
|
||||||
|
return _self;
|
||||||
|
|
||||||
|
} // end get
|
||||||
|
|
||||||
|
} // end class TagsList
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.htmlcheck.tags;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.HTMLTagSet;
|
||||||
|
|
||||||
|
class WBR_Tag extends HTMLTag
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
WBR_Tag()
|
||||||
|
{
|
||||||
|
super("WBR",false,HTMLTagSet.BLOCK);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Overrides from class HTMLTag
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String rewrite(String tag_data, boolean is_closing, HTMLTagSite site)
|
||||||
|
{
|
||||||
|
site.controlMessage("WBR",null);
|
||||||
|
return super.rewrite(tag_data,is_closing,site);
|
||||||
|
|
||||||
|
} // end rewrite
|
||||||
|
|
||||||
|
} // end class WBR_Tag
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.iface;
|
||||||
|
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
|
public interface HTMLChecker extends ObjectStore
|
||||||
|
{
|
||||||
|
public void append(String str);
|
||||||
|
|
||||||
|
public void append(Reader r);
|
||||||
|
|
||||||
|
public void finish();
|
||||||
|
|
||||||
|
public void reset();
|
||||||
|
|
||||||
|
public String getValue();
|
||||||
|
|
||||||
|
public int getLength();
|
||||||
|
|
||||||
|
public int getLines();
|
||||||
|
|
||||||
|
public int getCounter(String namespace, String name);
|
||||||
|
|
||||||
|
} // end interface HTMLChecker
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.iface;
|
||||||
|
|
||||||
|
public interface HTMLCheckerConfigRegister
|
||||||
|
{
|
||||||
|
public ComponentShutdown registerConfigurator(HTMLCheckerConfigurator cfg);
|
||||||
|
|
||||||
|
} // end interface HTMLCheckerConfigRegister
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.iface;
|
||||||
|
|
||||||
|
public interface HTMLCheckerConfigurator
|
||||||
|
{
|
||||||
|
public void configure(HTMLCheckerProfile profile);
|
||||||
|
|
||||||
|
} // end interface HTMLCheckerConfigurator
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.iface;
|
||||||
|
|
||||||
|
public interface HTMLCheckerProfile extends ObjectProvider
|
||||||
|
{
|
||||||
|
public void addOutputFilter(HTMLOutputFilter filter);
|
||||||
|
|
||||||
|
public void addRawOutputFilter(HTMLOutputFilter filter);
|
||||||
|
|
||||||
|
public void addStringRewriter(HTMLRewriter rewriter);
|
||||||
|
|
||||||
|
public void addWordRewriter(HTMLRewriter rewriter);
|
||||||
|
|
||||||
|
public void addTagRewriter(HTMLRewriter rewriter);
|
||||||
|
|
||||||
|
public void addParenRewriter(HTMLRewriter rewriter);
|
||||||
|
|
||||||
|
public void addBracketRewriter(HTMLRewriter rewriter);
|
||||||
|
|
||||||
|
public void addBraceRewriter(HTMLRewriter rewriter);
|
||||||
|
|
||||||
|
} // end interface HTMLCheckerProfile
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.iface;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.except.DatabaseException;
|
||||||
|
|
||||||
|
public interface HTMLCheckerService
|
||||||
|
{
|
||||||
|
public HTMLChecker createHTMLChecker(String profile_namespace, String profile_name) throws DatabaseException;
|
||||||
|
|
||||||
|
} // end interface HTMLCheckerService
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.iface;
|
||||||
|
|
||||||
|
public interface HTMLOutputFilter
|
||||||
|
{
|
||||||
|
public boolean tryOutputCharacter(StringBuffer buf, char ch);
|
||||||
|
|
||||||
|
public boolean matchCharacter(char ch);
|
||||||
|
|
||||||
|
public int lengthNoMatch(String s);
|
||||||
|
|
||||||
|
} // end interface HTMLOutputFilter
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.iface;
|
||||||
|
|
||||||
|
import com.silverwrist.dynamo.htmlcheck.MarkupData;
|
||||||
|
import com.silverwrist.dynamo.util.QualifiedNameKey;
|
||||||
|
|
||||||
|
public interface HTMLRewriter
|
||||||
|
{
|
||||||
|
public QualifiedNameKey getName();
|
||||||
|
|
||||||
|
public MarkupData rewrite(String data, String prefix, String suffix, HTMLRewriterSite site);
|
||||||
|
|
||||||
|
} // end interface HTMLRewriter
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
* (the "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Venice Web Communities System.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.dynamo.iface;
|
||||||
|
|
||||||
|
public interface HTMLRewriterSite extends ObjectProvider
|
||||||
|
{
|
||||||
|
public String getAttribute(String namespace, String name);
|
||||||
|
|
||||||
|
} // end interface HTMLRewriterSite
|
|
@ -327,4 +327,19 @@ public class PropertyUtils
|
||||||
|
|
||||||
} // end getPropertyNoErr
|
} // end getPropertyNoErr
|
||||||
|
|
||||||
|
public static Object getPropertyDefault(ObjectProvider prov, String namespace, String name, Object def)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{ // try to get it
|
||||||
|
return prov.getObject(namespace,name);
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (NoSuchObjectException e)
|
||||||
|
{ // we don't have the property - return the default value
|
||||||
|
return def;
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
} // end getPropertyNoErr
|
||||||
|
|
||||||
} // end class PropertyUtils
|
} // end class PropertyUtils
|
||||||
|
|
Loading…
Reference in New Issue
Block a user