Skip to content

Commit

Permalink
Update release notes wrt #127
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 19, 2021
1 parent 5ba99cd commit 56b2213
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 44 deletions.
6 changes: 6 additions & 0 deletions release-notes/CREDITS
Expand Up @@ -48,3 +48,9 @@ Daniel Kulp (dkulp@github)

* Contributed fix for #103: Issue caused by MSV shading
(6.2.0)

Chris Trenkamp (ChrisTrenkamp@github)

* Reported #127, suggested fix: Invalid attributes producing extra null characters
during DTD validation
(6.2.6)
2 changes: 2 additions & 0 deletions release-notes/VERSION
Expand Up @@ -7,6 +7,8 @@ Project: woodstox
6.2.6 (not yet released)

#125: `ArrayIndexOutOfBoundsException` for UTF-32 encoded data
#127: Invalid attributes producing extra null characters during DTD validation
(repported by Chris T)

6.2.5 (06-Apr-2021)

Expand Down
83 changes: 39 additions & 44 deletions src/main/java/com/ctc/wstx/dtd/DTDValidator.java
Expand Up @@ -37,10 +37,10 @@ public class DTDValidator
extends DTDValidatorBase
{
/*
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Configuration
///////////////////////////////////////
*/
///////////////////////////////////////////////////////////////////////
*/

/**
* Determines if identical problems (definition of the same element,
Expand All @@ -51,10 +51,10 @@ public class DTDValidator
protected boolean mReportDuplicateErrors = false;

/*
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Id/idref state
///////////////////////////////////////
*/
///////////////////////////////////////////////////////////////////////
*/

/**
* Information about declared and referenced element ids (unique
Expand All @@ -63,10 +63,10 @@ public class DTDValidator
protected ElementIdMap mIdMap = null;

/*
///////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Element def/spec/validator stack, state
///////////////////////////////////////////
*/
///////////////////////////////////////////////////////////////////////
*/

/**
* Stack of validators for open elements
Expand All @@ -79,26 +79,26 @@ public class DTDValidator
*/
protected BitSet mCurrSpecialAttrs = null;

boolean mCurrHasAnyFixed = false;
protected boolean mCurrHasAnyFixed = false;

/*
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Temporary helper objects
///////////////////////////////////////
*/
///////////////////////////////////////////////////////////////////////
*/

/**
* Reusable lazily instantiated BitSet; needed to keep track of
* missing 'special' attributes (required ones, ones with default
* values)
*/
BitSet mTmpSpecialAttrs;
protected BitSet mTmpSpecialAttrs;

/*
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Life-cycle
///////////////////////////////////////
*/
///////////////////////////////////////////////////////////////////////
*/

public DTDValidator(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefaults,
Map<PrefixedName,DTDElement> elemSpecs, Map<String,EntityDecl> genEntities)
Expand All @@ -111,10 +111,10 @@ public DTDValidator(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefau
public final boolean reallyValidating() { return true; }

/*
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// XMLValidator implementation
///////////////////////////////////////
*/
///////////////////////////////////////////////////////////////////////
*/

//public XMLValidationSchema getSchema();

Expand Down Expand Up @@ -208,11 +208,10 @@ public String validateAttribute(String localName, String uri,
// Only report error if not already recovering from an error:
if (mCurrElem != null) {
reportValidationProblem(ErrorConsts.ERR_VLD_UNKNOWN_ATTR,
mCurrElem.toString(), mTmpKey.toString());
mCurrElem.toString(), mTmpKey.toString());
}
/* [WSTX-190] NPE if we continued (after reported didn't
* throw an exception); nothing more to do, let's leave
*/
// [WSTX-190] NPE if we continued (after reported didn't
// throw an exception); nothing more to do, let's leave
return value;
}
int index = mAttrCount++;
Expand All @@ -239,21 +238,19 @@ public String validateAttribute(String localName, String uri,

@Override
public String validateAttribute(String localName, String uri,
String prefix,
char[] valueChars, int valueStart,
int valueEnd)
String prefix,
char[] valueChars, int valueStart, int valueEnd)
throws XMLStreamException
{
DTDAttribute attr = mCurrAttrDefs.get(mTmpKey.reset(prefix, localName));
if (attr == null) {
// Only report error if not already covering from an error:
if (mCurrElem != null) {
reportValidationProblem(ErrorConsts.ERR_VLD_UNKNOWN_ATTR,
mCurrElem.toString(), mTmpKey.toString());
mCurrElem.toString(), mTmpKey.toString());
}
/* [WSTX-190] NPE if we continued (after reported didn't
* throw an exception); nothing more to do, let's leave
*/
// [WSTX-190] NPE if we continued (after reported didn't
// throw an exception); nothing more to do, let's leave
return new String(valueChars, valueStart, valueEnd-valueStart);
}
int index = mAttrCount++;
Expand All @@ -278,7 +275,7 @@ public String validateAttribute(String localName, String uri,
}
if (!match) {
String act = (result == null) ?
new String(valueChars, valueStart, valueEnd) : result;
new String(valueChars, valueStart, valueEnd-valueStart) : result;
reportValidationProblem("Value of #FIXED attribute \""+attr+"\" (element <"+mCurrElem+">) not \""+exp+"\" as expected, but \""+act+"\"");
}
}
Expand Down Expand Up @@ -381,9 +378,9 @@ public void validationCompleted(boolean eod) throws XMLStreamException
}

/*
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Package methods, accessors
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
*/

@Override
Expand All @@ -395,27 +392,25 @@ protected ElementIdMap getIdMap() {
}

/*
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Internal methods
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////
*/

protected void checkIdRefs()
throws XMLStreamException
{
/* 02-Oct-2004, TSa: Now we can also check that all id references
* pointed to ids that actually are defined
*/
// 02-Oct-2004, TSa: Now we can also check that all id references
// pointed to ids that actually are defined
if (mIdMap != null) {
ElementId ref = mIdMap.getFirstUndefined();
if (ref != null) { // problem!
reportValidationProblem("Undefined id '"+ref.getId()
+"': referenced from element <"
+ref.getElemName()+">, attribute '"
+ref.getAttrName()+"'",
ref.getLocation());
+"': referenced from element <"
+ref.getElemName()+">, attribute '"
+ref.getAttrName()+"'",
ref.getLocation());
}
}
}

}

0 comments on commit 56b2213

Please sign in to comment.