~ubuntu-branches/ubuntu/precise/xerces-c/precise-security

« back to all changes in this revision

Viewing changes to src/xercesc/internal/XSAXMLScanner.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jay Berkenbilt
  • Date: 2009-12-05 14:58:32 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091205145832-378dg3x72mdzfzup
Tags: 3.1.0~rc1-1
* New upstream release; public release candidate uploaded at request of
  upstream.
* Updated source format to '3.0 (quilt)'

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 */
17
17
 
18
18
/*
19
 
 * $Id: XSAXMLScanner.cpp 696218 2008-09-17 09:31:41Z borisk $
 
19
 * $Id: XSAXMLScanner.cpp 833045 2009-11-05 13:21:27Z borisk $
20
20
 */
21
21
 
22
22
 
267
267
    //  Now, since we might have to update the namespace map for this element,
268
268
    //  but we don't have the element decl yet, we just tell the element stack
269
269
    //  to expand up to get ready.
270
 
    unsigned int elemDepth = fElemStack.addLevel();
 
270
    XMLSize_t elemDepth = fElemStack.addLevel();
271
271
    fElemStack.setValidationFlag(fValidate);
272
272
    fElemStack.setPrefixColonPos(prefixColonPos);
273
273
 
343
343
 
344
344
    //  We do something different here according to whether we found the
345
345
    //  element or not.
 
346
    bool bXsiTypeSet= (fValidator)?((SchemaValidator*)fValidator)->getIsXsiTypeSet():false;
346
347
    if (wasAdded || !elemDecl->isDeclared())
347
348
    {
348
 
        if (laxThisOne) {
 
349
        if (laxThisOne && !bXsiTypeSet) {
349
350
            fValidate = false;
350
351
            fElemStack.setValidationFlag(fValidate);
351
352
        }
357
358
            // faulted-in, was not an element in the grammar pool originally
358
359
            elemDecl->setCreateReason(XMLElementDecl::JustFaultIn);
359
360
 
360
 
            fValidator->emitError
361
 
            (
362
 
                XMLValid::ElementNotDefined, elemDecl->getFullName()
363
 
            );
 
361
            if(!bXsiTypeSet)
 
362
                fValidator->emitError
 
363
                (
 
364
                    XMLValid::ElementNotDefined, elemDecl->getFullName()
 
365
                );
364
366
        }
365
367
    }
366
368
 
433
435
    {
434
436
        // clean up after ourselves:
435
437
        // clear the map used to detect duplicate attributes
436
 
        fUndeclaredAttrRegistryNS->removeAll();
 
438
        fUndeclaredAttrRegistry->removeAll();
437
439
    }
438
440
 
439
441
    // Since the element may have default values, call start tag now regardless if it is empty or not
573
575
        , XMLReader::Type_General
574
576
        , XMLReader::Source_External
575
577
        , fCalculateSrcOfs
 
578
        , fLowWaterMark
576
579
    );
577
580
 
578
581
    if (!newReader) {
603
606
        // though their buckets will still be tied up
604
607
        resetUIntPool();
605
608
    }
606
 
    fUndeclaredAttrRegistryNS->removeAll();
 
609
    fUndeclaredAttrRegistry->removeAll();
607
610
}
608
611
 
609
612
 
661
664
                const XMLCh* valuePtr = curPair->getValue();
662
665
                const XMLCh* suffPtr = attName.getLocalPart();
663
666
 
664
 
                if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) {
665
 
                    fXsiType.set(valuePtr);
 
667
                if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) 
 
668
                {
 
669
                    // normalize the attribute according to schema whitespace facet
 
670
                    DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_QNAME);
 
671
                    ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, valuePtr, fXsiType, true);
666
672
                }
667
 
                else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL)
668
 
                         && XMLString::equals(valuePtr, SchemaSymbols::fgATTVAL_TRUE)) {
669
 
                    ((SchemaValidator*)fValidator)->setNillable(true);
 
673
                else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL))
 
674
                {
 
675
                    // normalize the attribute according to schema whitespace facet
 
676
                    XMLBuffer& fXsiNil = fBufMgr.bidOnBuffer();
 
677
                    DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_BOOLEAN);
 
678
                    ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, valuePtr, fXsiNil, true);
 
679
                    if(XMLString::equals(fXsiNil.getRawBuffer(), SchemaSymbols::fgATTVAL_TRUE))
 
680
                        ((SchemaValidator*)fValidator)->setNillable(true);
 
681
                    else if(XMLString::equals(fXsiNil.getRawBuffer(), SchemaSymbols::fgATTVAL_FALSE))
 
682
                        ((SchemaValidator*)fValidator)->setNillable(false);
 
683
                    else
 
684
                        emitError(XMLErrs::InvalidAttValue, fXsiNil.getRawBuffer(), valuePtr);
 
685
                    fBufMgr.releaseBuffer(fXsiNil);
670
686
                }
671
687
            }
672
688
        }