You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Schmidt, Maik, MTC-DTM, ST" <Ma...@PASSO.DE> on 2000/10/04 14:34:44 UTC

Small bug in XSPUtil.toMarkup?

Yo!

I think, I have found a small bug in XSPUtil.toMarkup, that leads to
problems with attribute values containing XML's special characters '<', '>'
and '&'.

So, if you call XSPUtil.toMarkup on a document containing the element
'<Service name="Park&Ride"/>', the function won't work properly, i.e.,
returning the string '<Service name="Park&amp;Ride"/>'.

In my opinion the problem is in the Method doMarkup:

case Node.ELEMENT_NODE: {
  Element element = (Element) node;

  buffer.append("<" + element.getTagName());

  NamedNodeMap attributes = element.getAttributes();
  int attributeCount = attributes.getLength();

  for (int i = 0; i < attributeCount; i++) {
    Attr attribute = (Attr) attributes.item(i);

    buffer.append(" ");
    buffer.append(attribute.getName());
    buffer.append("=\"");
    buffer.append(attribute.getValue());  //  This one has to be
'buffer.append(encodeMarkup(attribute.getValue()));'?
    buffer.append("\"");
  }

Best regards,

  Maik