You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The source of the problem is the built-in xml namespace http://www.w3.org/XML/1998/namespace.
Those entries are not included in the PREFIX and NAMESPACE NAME tables but
decoder knows that hey are there and that they got assigned index number '1'.
This is described in the spec, point 7.2.21 and 7.2.22.
Example xml:
<prefix1:root xmlns:prefix1="namespace1" xmlns:prefix2="namespace2" >
.... the content...
</prefix1:root>
Example prefix table:
1: xml (This entry is built-in and is not included in the
fastinfoset vocabulary table)
2: prefix1
3: prefix2
The easiest way to explain that is by using SAX decoder so during decoding the
DefaultHandler.startPrefixMapping method:
instead of receiving:
1. prefix="prefix1", uri="namespace1"
2. prefix="prefix2", uri="namespace2"
So during decoding all the prefixes and namespace names are shifted by one.
This bug can be fixed by replacing Decoder.decodeTableItems(QualifiedNameArray
array, boolean isAttribute) method below:
private void decodeTableItems(QualifiedNameArray array, boolean isAttribute)
throws FastInfosetException, IOException {
for (int i = 0; i < decodeNumberOfItemsOfSequence(); i++) {
final int b = read();
String prefix = "";
int prefixIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_PREFIX_FLAG) > 0)
{ throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.missingNamespace")); }
final int localNameIndex = decodeIntegerIndexOnSecondBit();
final String localName = _v.localName.get(localNameIndex);
QualifiedName qualifiedName = new QualifiedName(prefix,
namespaceName, localName,
prefixIndex, namespaceNameIndex, localNameIndex,
_charBuffer);
if (isAttribute) { qualifiedName.createAttributeValues(_duplicateAttributeVerifier.MAP_SIZE); }
array.add(qualifiedName);
}
}
By the method below (fixed lines are annotated):
private void decodeTableItems(QualifiedNameArray array, boolean isAttribute)
throws FastInfosetException, IOException {
for (int i = 0; i < decodeNumberOfItemsOfSequence(); i++) {
final int b = read();
String prefix = "";
int prefixIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_PREFIX_FLAG) > 0) { prefixIndex = decodeIntegerIndexOnSecondBit(); // fix for 7.2.21 prefix = _v.prefix._array[prefixIndex - 1]; }
String namespaceName = "";
int namespaceNameIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_NAME_FLAG) > 0) { namespaceNameIndex = decodeIntegerIndexOnSecondBit(); // fix for 7.2.22 namespaceName = _v.namespaceName._array[namespaceNameIndex - 1]; }
The source of the problem is the built-in xml namespace
http://www.w3.org/XML/1998/namespace.
Those entries are not included in the PREFIX and NAMESPACE NAME tables but
decoder knows that hey are there and that they got assigned index number '1'.
This is described in the spec, point 7.2.21 and 7.2.22.
Example xml:
<prefix1:root xmlns:prefix1="namespace1" xmlns:prefix2="namespace2" >
.... the content...
</prefix1:root>
Example prefix table:
1: xml (This entry is built-in and is not included in the
fastinfoset vocabulary table)
2: prefix1
3: prefix2
The easiest way to explain that is by using SAX decoder so during decoding the
DefaultHandler.startPrefixMapping method:
DefaultHandler.startPrefixMapping (String prefix, String uri)
receives the following notifications:
1. prefix="xml", uri="http://www.w3.org/XML/1998/namespace"
2. prefix="prefix1", uri="namespace1"
instead of receiving:
1. prefix="prefix1", uri="namespace1"
2. prefix="prefix2", uri="namespace2"
So during decoding all the prefixes and namespace names are shifted by one.
This bug can be fixed by replacing Decoder.decodeTableItems(QualifiedNameArray
array, boolean isAttribute) method below:
private void decodeTableItems(QualifiedNameArray array, boolean isAttribute)
throws FastInfosetException, IOException {
for (int i = 0; i < decodeNumberOfItemsOfSequence(); i++) {
final int b = read();
String prefix = "";
int prefixIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_PREFIX_FLAG) > 0)
{ prefixIndex = decodeIntegerIndexOnSecondBit(); prefix = _v.prefix._array[prefixIndex - 1]; }
String namespaceName = "";
int namespaceNameIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_NAME_FLAG) > 0)
{ namespaceNameIndex = decodeIntegerIndexOnSecondBit(); namespaceName = _v.namespaceName._array[namespaceNameIndex - 1]; }
if (namespaceName == "" && prefix != "")
{ throw new FastInfosetException(CommonResourceBundle.getInstance().getString("message.missingNamespace")); }
final int localNameIndex = decodeIntegerIndexOnSecondBit();
final String localName = _v.localName.get(localNameIndex);
QualifiedName qualifiedName = new QualifiedName(prefix,
namespaceName, localName,
prefixIndex, namespaceNameIndex, localNameIndex,
_charBuffer);
if (isAttribute) { qualifiedName.createAttributeValues(_duplicateAttributeVerifier.MAP_SIZE); }
array.add(qualifiedName);
}
}
By the method below (fixed lines are annotated):
private void decodeTableItems(QualifiedNameArray array, boolean isAttribute)
throws FastInfosetException, IOException {
for (int i = 0; i < decodeNumberOfItemsOfSequence(); i++) {
final int b = read();
String prefix = "";
int prefixIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_PREFIX_FLAG) > 0) { prefixIndex = decodeIntegerIndexOnSecondBit(); // fix for 7.2.21 prefix = _v.prefix._array[prefixIndex - 1]; }
String namespaceName = "";
int namespaceNameIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_NAME_FLAG) > 0) { namespaceNameIndex = decodeIntegerIndexOnSecondBit(); // fix for 7.2.22 namespaceName = _v.namespaceName._array[namespaceNameIndex - 1]; }
if (namespaceName == "" && prefix != "") { throw newFastInfosetException(CommonResourceBundle.getInstance().getString("message.missingNamespace")); }
final int localNameIndex = decodeIntegerIndexOnSecondBit();
final String localName = _v.localName.get(localNameIndex);
QualifiedName qualifiedName = new QualifiedName(prefix,
namespaceName, localName,
prefixIndex, namespaceNameIndex, localNameIndex,
_charBuffer);
if (isAttribute)
{ qualifiedName.createAttributeValues(_duplicateAttributeVerifier.MAP_SIZE); }
array.add(qualifiedName);
}
}
Environment
Operating System: All
Platform: All
Affected Versions
[current]
The text was updated successfully, but these errors were encountered: