From d59a23b8555851d9f73bd558bfbed65cda82fd19 Mon Sep 17 00:00:00 2001 From: Torsten Bergmann Date: Thu, 26 Oct 2023 01:16:57 +0200 Subject: [PATCH] Formatting and lints --- .../DTDCachingExternalEntityResolver.class.st | 4 + ...edExternalParsedEntityReplacement.class.st | 5 + src/XML-Parser/DTDDoctypeDefinition.class.st | 107 +++++++++++++----- src/XML-Parser/DTDDocumentValidator.class.st | 11 ++ .../DTDElementContentModelParser.class.st | 12 +- src/XML-Parser/DTDEntity.class.st | 21 +++- .../DTDEntityConfiguration.class.st | 7 +- .../DTDEnumerationListParser.class.st | 5 + .../DTDExternalEntityLimits.class.st | 9 ++ .../DTDExternalEntityResolver.class.st | 14 +++ ...alEntityResolverLimitingDecorator.class.st | 26 +++++ .../DTDExternalParameterParsedEntity.class.st | 1 + .../DTDExternalParsedEntity.class.st | 16 ++- .../DTDInternalParameterParsedEntity.class.st | 1 + .../DTDInternalParsedEntity.class.st | 7 +- .../DTDLiteralContentModelParser.class.st | 1 + ...MixedContentEnumerationListParser.class.st | 5 +- src/XML-Parser/DTDNotation.class.st | 13 ++- .../DTDNotationEnumerationListParser.class.st | 1 + src/XML-Parser/DTDParsedEntity.class.st | 8 +- ...edExternalParsedEntityReplacement.class.st | 5 + .../DTDStaticExternalEntityResolver.class.st | 16 +++ src/XML-Parser/DTDUnparsedEntity.class.st | 14 ++- ...ableExternalParameterParsedEntity.class.st | 1 + ...DUnresolvableExternalParsedEntity.class.st | 11 +- src/XML-Parser/ManifestXMLParser.class.st | 29 +++++ 26 files changed, 298 insertions(+), 52 deletions(-) create mode 100644 src/XML-Parser/ManifestXMLParser.class.st diff --git a/src/XML-Parser/DTDCachingExternalEntityResolver.class.st b/src/XML-Parser/DTDCachingExternalEntityResolver.class.st index fbec94ff..28dfc931 100644 --- a/src/XML-Parser/DTDCachingExternalEntityResolver.class.st +++ b/src/XML-Parser/DTDCachingExternalEntityResolver.class.st @@ -72,21 +72,25 @@ DTDCachingExternalEntityResolver class >> maxCachedEntities: anInteger [ { #category : #clearing } DTDCachingExternalEntityResolver >> clearEntityCache [ + self class clearEntityCache ] { #category : #accessing } DTDCachingExternalEntityResolver >> maxCachedEntities [ + ^ self class maxCachedEntities ] { #category : #accessing } DTDCachingExternalEntityResolver >> maxCachedEntities: anInteger [ + self class maxCachedEntities: anInteger ] { #category : #private } DTDCachingExternalEntityResolver >> resolveNonLocalExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + | uri | uri := anXMLURIOrURIString asXMLURI. diff --git a/src/XML-Parser/DTDDecodedResolvedExternalParsedEntityReplacement.class.st b/src/XML-Parser/DTDDecodedResolvedExternalParsedEntityReplacement.class.st index 5bf4d923..64f062f2 100644 --- a/src/XML-Parser/DTDDecodedResolvedExternalParsedEntityReplacement.class.st +++ b/src/XML-Parser/DTDDecodedResolvedExternalParsedEntityReplacement.class.st @@ -17,16 +17,19 @@ DTDDecodedResolvedExternalParsedEntityReplacement class >> contents: aString [ { #category : #accessing } DTDDecodedResolvedExternalParsedEntityReplacement >> contents [ + ^ contents ] { #category : #testing } DTDDecodedResolvedExternalParsedEntityReplacement >> isEmpty [ + ^ self contents isEmpty ] { #category : #printing } DTDDecodedResolvedExternalParsedEntityReplacement >> printOn: aStream [ + super printOn: aStream. aStream @@ -37,10 +40,12 @@ DTDDecodedResolvedExternalParsedEntityReplacement >> printOn: aStream [ { #category : #accessing } DTDDecodedResolvedExternalParsedEntityReplacement >> readStream [ + ^ self contents readStream ] { #category : #initialization } DTDDecodedResolvedExternalParsedEntityReplacement >> setContents: aString [ + contents := aString ] diff --git a/src/XML-Parser/DTDDoctypeDefinition.class.st b/src/XML-Parser/DTDDoctypeDefinition.class.st index b7d7a187..0604f1fb 100644 --- a/src/XML-Parser/DTDDoctypeDefinition.class.st +++ b/src/XML-Parser/DTDDoctypeDefinition.class.st @@ -20,6 +20,7 @@ Class { { #category : #adding } DTDDoctypeDefinition >> addExternalGeneralEntity: aName resolver: aResolver publicID: aPublicID systemID: aSystemID baseURI: aBaseURIString [ + (self generalEntities includesKey: aName) ifTrue: [^ nil]. ^ self generalEntities @@ -35,8 +36,10 @@ DTDDoctypeDefinition >> addExternalGeneralEntity: aName resolver: aResolver publ { #category : #adding } DTDDoctypeDefinition >> addExternalParameterEntity: aName resolver: aResolver publicID: aPublicID systemID: aSystemID baseURI: aBaseURIString [ + (self parameterEntities includesKey: aName) ifTrue: [^ nil]. + ^ self parameterEntities at: aName put: @@ -50,6 +53,7 @@ DTDDoctypeDefinition >> addExternalParameterEntity: aName resolver: aResolver pu { #category : #adding } DTDDoctypeDefinition >> addGeneralEntitiesFrom: aDoctypeDefinition [ + aDoctypeDefinition generalEntities keysAndValuesDo: [:name :entity | self generalEntities at: name @@ -58,8 +62,10 @@ DTDDoctypeDefinition >> addGeneralEntitiesFrom: aDoctypeDefinition [ { #category : #adding } DTDDoctypeDefinition >> addInternalGeneralEntity: aName replacement: aReplacement baseURI: aBaseURIString [ + (self generalEntities includesKey: aName) ifTrue: [^ nil]. + ^ self generalEntities at: aName put: @@ -71,8 +77,10 @@ DTDDoctypeDefinition >> addInternalGeneralEntity: aName replacement: aReplacemen { #category : #adding } DTDDoctypeDefinition >> addInternalParameterEntity: aName replacement: aReplacement baseURI: aBaseURIString [ + (self parameterEntities includesKey: aName) ifTrue: [^ nil]. + ^ self parameterEntities at: aName put: @@ -84,8 +92,10 @@ DTDDoctypeDefinition >> addInternalParameterEntity: aName replacement: aReplacem { #category : #adding } DTDDoctypeDefinition >> addNotation: aName publicID: aPublicID systemID: aSystemID [ + (self notations includesKey: aName) ifTrue: [^ nil]. + ^ self notations at: aName put: @@ -97,8 +107,10 @@ DTDDoctypeDefinition >> addNotation: aName publicID: aPublicID systemID: aSystem { #category : #adding } DTDDoctypeDefinition >> addStandaloneExternalExternalGeneralEntity: aName resolver: aResolver publicID: aPublicID systemID: aSystemID baseURI: aBaseURIString [ + (self generalEntities includesKey: aName) ifTrue: [^ nil]. + ^ self generalEntities at: aName put: @@ -112,8 +124,10 @@ DTDDoctypeDefinition >> addStandaloneExternalExternalGeneralEntity: aName resolv { #category : #adding } DTDDoctypeDefinition >> addStandaloneExternalInternalGeneralEntity: aName replacement: aReplacement baseURI: aBaseURIString [ + (self generalEntities includesKey: aName) ifTrue: [^ nil]. + ^ self generalEntities at: aName put: @@ -127,12 +141,12 @@ DTDDoctypeDefinition >> addStandaloneExternalInternalGeneralEntity: aName replac DTDDoctypeDefinition >> addStandaloneExternalValidatorForAttributeIn: anElement named: anAttribute type: aType defaultPragma: aDefaultPragma defaultValue: aDefaultValue [ | attributes | - attributes := - self attributeValidators - at: anElement - ifAbsentPut: [Dictionary new]. + attributes := self attributeValidators + at: anElement + ifAbsentPut: [Dictionary new]. (attributes includesKey: anAttribute) ifTrue: [^ nil]. + ^ attributes at: anAttribute put: @@ -147,8 +161,10 @@ DTDDoctypeDefinition >> addStandaloneExternalValidatorForAttributeIn: anElement { #category : #adding } DTDDoctypeDefinition >> addStandaloneExternalValidatorForElement: anElement contentModel: aContentModel [ + (self elementValidators includesKey: anElement) ifTrue: [^ nil]. + ^ self elementValidators at: anElement put: @@ -160,8 +176,10 @@ DTDDoctypeDefinition >> addStandaloneExternalValidatorForElement: anElement cont { #category : #adding } DTDDoctypeDefinition >> addUnparsedEntity: aName publicID: aPublicID systemID: aSystemID ndata: aNotation [ + (self generalEntities includesKey: aName) ifTrue: [^ nil]. + ^ self generalEntities at: aName put: @@ -177,8 +195,10 @@ DTDDoctypeDefinition >> addUnparsedEntity: aName publicID: aPublicID systemID: a { #category : #adding } DTDDoctypeDefinition >> addUnresolvableExternalGeneralEntity: aName [ + (self generalEntities includesKey: aName) ifTrue: [^ nil]. + ^ self generalEntities at: aName put: (DTDUnresolvableExternalGeneralParsedEntity named: aName) @@ -188,6 +208,7 @@ DTDDoctypeDefinition >> addUnresolvableExternalGeneralEntity: aName [ DTDDoctypeDefinition >> addUnresolvableExternalParameterEntity: aName [ (self parameterEntities includesKey: aName) ifTrue: [^ nil]. + ^ self parameterEntities at: aName put: (DTDUnresolvableExternalParameterParsedEntity named: aName) @@ -197,12 +218,12 @@ DTDDoctypeDefinition >> addUnresolvableExternalParameterEntity: aName [ DTDDoctypeDefinition >> addValidatorForAttributeIn: anElement named: anAttribute type: aType defaultPragma: aDefaultPragma defaultValue: aDefaultValue [ | attributes | - attributes := - self attributeValidators - at: anElement - ifAbsentPut: [Dictionary new]. + attributes := self attributeValidators + at: anElement + ifAbsentPut: [Dictionary new]. (attributes includesKey: anAttribute) ifTrue: [^ nil]. + ^ attributes at: anAttribute put: @@ -217,8 +238,10 @@ DTDDoctypeDefinition >> addValidatorForAttributeIn: anElement named: anAttribute { #category : #adding } DTDDoctypeDefinition >> addValidatorForElement: anElement contentModel: aContentModel [ + (self elementValidators includesKey: anElement) ifTrue: [^ nil]. + ^ self elementValidators at: anElement put: @@ -229,11 +252,13 @@ DTDDoctypeDefinition >> addValidatorForElement: anElement contentModel: aContent { #category : #accessing } DTDDoctypeDefinition >> attributeValidators [ + ^ attributeValidators ifNil: [attributeValidators := Dictionary new] ] { #category : #accessing } DTDDoctypeDefinition >> attributeValidatorsAt: aName [ + ^ self attributeValidatorsAt: aName ifAbsent: [nil] @@ -241,6 +266,7 @@ DTDDoctypeDefinition >> attributeValidatorsAt: aName [ { #category : #accessing } DTDDoctypeDefinition >> attributeValidatorsAt: aName ifAbsent: aBlock [ + ^ self attributeValidators at: aName ifAbsent: aBlock @@ -248,16 +274,19 @@ DTDDoctypeDefinition >> attributeValidatorsAt: aName ifAbsent: aBlock [ { #category : #accessing } DTDDoctypeDefinition >> elementIDValidator [ + ^ elementIDValidator ifNil: [elementIDValidator := XMLElementIDValidator new] ] { #category : #accessing } DTDDoctypeDefinition >> elementValidators [ + ^ elementValidators ifNil: [elementValidators := Dictionary new] ] { #category : #accessing } DTDDoctypeDefinition >> elementValidatorsAt: aName [ + ^ self elementValidatorsAt: aName ifAbsent: [nil] @@ -265,6 +294,7 @@ DTDDoctypeDefinition >> elementValidatorsAt: aName [ { #category : #accessing } DTDDoctypeDefinition >> elementValidatorsAt: aName ifAbsent: aBlock [ + ^ self elementValidators at: aName ifAbsent: aBlock @@ -272,11 +302,13 @@ DTDDoctypeDefinition >> elementValidatorsAt: aName ifAbsent: aBlock [ { #category : #accessing } DTDDoctypeDefinition >> generalEntities [ + ^ generalEntities ifNil: [generalEntities := Dictionary new] ] { #category : #accessing } DTDDoctypeDefinition >> generalEntityAt: aName [ + ^ self generalEntityAt: aName ifAbsent: [nil] @@ -284,6 +316,7 @@ DTDDoctypeDefinition >> generalEntityAt: aName [ { #category : #accessing } DTDDoctypeDefinition >> generalEntityAt: aName ifAbsent: aBlock [ + ^ self generalEntities at: aName ifAbsent: aBlock @@ -292,14 +325,16 @@ DTDDoctypeDefinition >> generalEntityAt: aName ifAbsent: aBlock [ { #category : #testing } DTDDoctypeDefinition >> hasAttributeValidators [ "optimized to avoid lazy initialization" + attributeValidators == nil ifTrue: [^ false]. - ^ attributeValidators size > 0. + ^ attributeValidators size > 0 ] { #category : #testing } DTDDoctypeDefinition >> hasElementIDReferences [ "direct access to avoid lazy initialization" + ^ elementIDValidator notNil and: [elementIDValidator hasIDReferences] ] @@ -307,6 +342,7 @@ DTDDoctypeDefinition >> hasElementIDReferences [ { #category : #testing } DTDDoctypeDefinition >> hasElementIDs [ "direct access to avoid lazy initialization" + ^ elementIDValidator notNil and: [elementIDValidator hasIDs] ] @@ -314,13 +350,15 @@ DTDDoctypeDefinition >> hasElementIDs [ { #category : #testing } DTDDoctypeDefinition >> hasElementValidators [ "optimized to avoid lazy initialization" + elementValidators == nil ifTrue: [^ false]. - ^ elementValidators size > 0. + ^ elementValidators size > 0 ] { #category : #testing } DTDDoctypeDefinition >> hasEntities [ + ^ self hasGeneralEntities or: [self hasParameterEntities or: [self hasUnparsedEntities]] @@ -329,12 +367,14 @@ DTDDoctypeDefinition >> hasEntities [ { #category : #testing } DTDDoctypeDefinition >> hasGeneralEntities [ "direct access to avoid lazy initialization" + ^ generalEntities notNil and: [generalEntities notEmpty] ] { #category : #testing } DTDDoctypeDefinition >> hasNotationAttributeValidators [ + ^ self hasAttributeValidators and: [self unparsedEntityValidator hasNotationAttributeValidators] ] @@ -342,62 +382,66 @@ DTDDoctypeDefinition >> hasNotationAttributeValidators [ { #category : #testing } DTDDoctypeDefinition >> hasNotations [ "direct access to avoid lazy initialization" - ^ notations notNil - and: [notations notEmpty] + + ^ notations notNil and: [ notations notEmpty ] ] { #category : #testing } DTDDoctypeDefinition >> hasParameterEntities [ "direct access to avoid lazy initialization" - ^ parameterEntities notNil - and: [parameterEntities notEmpty] + + ^ parameterEntities notNil and: [ parameterEntities notEmpty ] ] { #category : #testing } DTDDoctypeDefinition >> hasRoot [ - ^ root notNil and: [root notEmpty] + + ^ root notNil and: [ root notEmpty ] ] { #category : #testing } DTDDoctypeDefinition >> hasUnparsedEntities [ "direct access to avoid lazy initialization" - ^ unparsedEntities notNil - and: [unparsedEntities notEmpty] + + ^ unparsedEntities notNil and: [ unparsedEntities notEmpty ] ] { #category : #'instance creation' } DTDDoctypeDefinition >> newValidator [ + ^ DTDDocumentValidator doctypeDefinition: self ] { #category : #accessing } DTDDoctypeDefinition >> notations [ - ^ notations ifNil: [notations := Dictionary new] + + ^ notations ifNil: [ notations := Dictionary new ] ] { #category : #accessing } DTDDoctypeDefinition >> parameterEntities [ - ^ parameterEntities ifNil: [parameterEntities := Dictionary new] + + ^ parameterEntities ifNil: [ parameterEntities := Dictionary new ] ] { #category : #accessing } DTDDoctypeDefinition >> parameterEntityAt: aName [ - ^ self - parameterEntityAt: aName - ifAbsent: [nil] + + ^ self parameterEntityAt: aName ifAbsent: [ nil ] ] { #category : #accessing } DTDDoctypeDefinition >> parameterEntityAt: aName ifAbsent: aBlock [ - ^ self parameterEntities - at: aName - ifAbsent: aBlock + + ^ self parameterEntities at: aName ifAbsent: aBlock ] { #category : #processing } DTDDoctypeDefinition >> processStartTag: anElement attributes: aDictionary [ + self hasAttributeValidators ifFalse: [^ self]. + (self attributeValidatorsAt: anElement ifAbsent: [^ self]) @@ -406,33 +450,39 @@ DTDDoctypeDefinition >> processStartTag: anElement attributes: aDictionary [ { #category : #removing } DTDDoctypeDefinition >> removeElementIDReferences [ + self hasElementIDReferences ifTrue: [self elementIDValidator removeIDReferences] ] { #category : #removing } DTDDoctypeDefinition >> removeElementIDs [ + self hasElementIDs ifTrue: [self elementIDValidator removeIDs] ] { #category : #accessing } DTDDoctypeDefinition >> root [ - ^ root ifNil: [root := ''] + + ^ root ifNil: [ root := '' ] ] { #category : #accessing } DTDDoctypeDefinition >> root: aRootElement [ + root := aRootElement ] { #category : #accessing } DTDDoctypeDefinition >> unparsedEntities [ - ^ unparsedEntities ifNil: [unparsedEntities := Dictionary new] + + ^ unparsedEntities ifNil: [ unparsedEntities := Dictionary new ] ] { #category : #accessing } DTDDoctypeDefinition >> unparsedEntityValidator [ + ^ unparsedEntityValidator ifNil: [ unparsedEntityValidator := @@ -443,8 +493,9 @@ DTDDoctypeDefinition >> unparsedEntityValidator [ { #category : #validation } DTDDoctypeDefinition >> validateCompletedDefinition [ + self hasUnparsedEntities ifTrue: [self unparsedEntityValidator validateUnparsedEntityDeclarations]. self hasNotationAttributeValidators - ifTrue: [self unparsedEntityValidator validateNotationAttributeDeclarationDefaults]. + ifTrue: [self unparsedEntityValidator validateNotationAttributeDeclarationDefaults] ] diff --git a/src/XML-Parser/DTDDocumentValidator.class.st b/src/XML-Parser/DTDDocumentValidator.class.st index 5b4aa133..9dad17ba 100644 --- a/src/XML-Parser/DTDDocumentValidator.class.st +++ b/src/XML-Parser/DTDDocumentValidator.class.st @@ -17,6 +17,7 @@ DTDDocumentValidator class >> doctypeDefinition: aDoctypeDefinition [ { #category : #accessing } DTDDocumentValidator >> attributeValidatorsFor: anElement ifNone: aBlock [ + ^ self doctypeDefinition attributeValidatorsAt: anElement ifAbsent: aBlock @@ -24,16 +25,19 @@ DTDDocumentValidator >> attributeValidatorsFor: anElement ifNone: aBlock [ { #category : #accessing } DTDDocumentValidator >> doctypeDefinition [ + ^ doctypeDefinition ] { #category : #accessing } DTDDocumentValidator >> doctypeDefinition: aDoctypeDefinition [ + doctypeDefinition := aDoctypeDefinition ] { #category : #accessing } DTDDocumentValidator >> elementValidatorFor: anElement ifNone: aBlock [ + ^ self doctypeDefinition elementValidatorsAt: anElement ifAbsent: aBlock @@ -41,6 +45,7 @@ DTDDocumentValidator >> elementValidatorFor: anElement ifNone: aBlock [ { #category : #private } DTDDocumentValidator >> errorInvalidRootElement: anElement [ + XMLValidationException formatSignal: 'Root element must be <{1}> according to DOCTYPE declaration, not <{2}>' @@ -50,16 +55,19 @@ DTDDocumentValidator >> errorInvalidRootElement: anElement [ { #category : #testing } DTDDocumentValidator >> hasAttributeValidators [ + ^ self doctypeDefinition hasAttributeValidators ] { #category : #testing } DTDDocumentValidator >> hasElementValidators [ + ^ self doctypeDefinition hasElementValidators ] { #category : #validating } DTDDocumentValidator >> unvalidatedAttributes: anAttributeCollection inElement: anElement [ + XMLValidationException formatSignal: 'Undeclared attribute "{1}" in element <{2}>' with: anAttributeCollection anyOne @@ -68,6 +76,7 @@ DTDDocumentValidator >> unvalidatedAttributes: anAttributeCollection inElement: { #category : #validating } DTDDocumentValidator >> unvalidatedElement: anElement [ + XMLValidationException formatSignal: 'Undeclared element <{1}>' with: anElement @@ -75,12 +84,14 @@ DTDDocumentValidator >> unvalidatedElement: anElement [ { #category : #validating } DTDDocumentValidator >> validateIDReferences [ + self doctypeDefinition hasElementIDReferences ifTrue: [self doctypeDefinition elementIDValidator validateIDReferences] ] { #category : #validating } DTDDocumentValidator >> validateRootElement: anElement [ + (self doctypeDefinition hasRoot and: [self doctypeDefinition root ~= anElement]) ifTrue: [self errorInvalidRootElement: anElement] diff --git a/src/XML-Parser/DTDElementContentModelParser.class.st b/src/XML-Parser/DTDElementContentModelParser.class.st index 502f966c..4b27798e 100644 --- a/src/XML-Parser/DTDElementContentModelParser.class.st +++ b/src/XML-Parser/DTDElementContentModelParser.class.st @@ -65,24 +65,27 @@ DTDElementContentModelParser class >> standaloneExternalClass [ { #category : #private } DTDElementContentModelParser >> applyBinaryOperatorOnStack [ + self applyOperator: binaryOperatorStack removeLast ] { #category : #private } DTDElementContentModelParser >> applyOperator: aCharacter [ + nfaBuilder perform: (OperatorApplicators at: aCharacter asciiValue) ] { #category : #defaults } DTDElementContentModelParser >> elementValidatorClass [ + ^ XMLDFAElementContentElementValidator ] { #category : #private } DTDElementContentModelParser >> hasBinaryOperatorOnStack [ - ^ binaryOperatorStack size > 0 - and: [binaryOperatorStack last ~~ $(] + + ^ binaryOperatorStack size > 0 and: [ binaryOperatorStack last ~~ $( ] ] { #category : #parsing } @@ -117,11 +120,13 @@ DTDElementContentModelParser >> parse [ { #category : #private } DTDElementContentModelParser >> parseBinaryOperator: aCharacter [ + binaryOperatorStack addLast: aCharacter ] { #category : #private } DTDElementContentModelParser >> parseClosingParenthesis: aCharacter [ + self popRemainingBinaryOperators. (binaryOperatorStack size > 0 and: [binaryOperatorStack last == $(]) @@ -130,11 +135,13 @@ DTDElementContentModelParser >> parseClosingParenthesis: aCharacter [ { #category : #private } DTDElementContentModelParser >> parseOpeningParenthesis: aCharacter [ + binaryOperatorStack addLast: $( ] { #category : #private } DTDElementContentModelParser >> parseUnaryOperator: aCharacter [ + self applyOperator: aCharacter ] @@ -151,6 +158,7 @@ DTDElementContentModelParser >> parserForSpecialCharacter: aCharacter [ { #category : #private } DTDElementContentModelParser >> popRemainingBinaryOperators [ + [self hasBinaryOperatorOnStack] whileTrue: [self applyBinaryOperatorOnStack] ] diff --git a/src/XML-Parser/DTDEntity.class.st b/src/XML-Parser/DTDEntity.class.st index d2ce1ff3..1050c1f0 100644 --- a/src/XML-Parser/DTDEntity.class.st +++ b/src/XML-Parser/DTDEntity.class.st @@ -23,46 +23,55 @@ DTDEntity class >> named: aName [ { #category : #converting } DTDEntity >> asReference [ + ^ String streamContents: [:stream | self printReferenceOn: stream] ] { #category : #testing } DTDEntity >> isExternal [ + ^ false ] { #category : #testing } DTDEntity >> isParameter [ + ^ false ] { #category : #testing } DTDEntity >> isStandaloneExternal [ + ^ false ] { #category : #testing } DTDEntity >> isUnparsed [ + ^ false ] { #category : #accessing } DTDEntity >> name [ + ^ name ifNil: [name := ''] ] { #category : #accessing } DTDEntity >> name: aName [ + name := aName ] { #category : #printing } DTDEntity >> printNameOn: aStream [ + aStream nextPutAll: self name ] { #category : #printing } DTDEntity >> printOn: aStream [ + super printOn: aStream. aStream nextPut: $(. @@ -72,25 +81,29 @@ DTDEntity >> printOn: aStream [ { #category : #printing } DTDEntity >> printReferenceOn: aStream [ + aStream nextPut: self referencePrefix; nextPutAll: self name; nextPut: $; ] -{ #category : #'private ' } +{ #category : #private } DTDEntity >> referencePrefix [ + ^ self isParameter - ifTrue: [$%] - ifFalse: [$&] + ifTrue: [ $% ] + ifFalse: [ $& ] ] { #category : #accessing } DTDEntity >> uri [ - ^ uri ifNil: [uri := ''] + + ^ uri ifNil: [ uri := '' ] ] { #category : #accessing } DTDEntity >> uri: aURIString [ + uri := aURIString ] diff --git a/src/XML-Parser/DTDEntityConfiguration.class.st b/src/XML-Parser/DTDEntityConfiguration.class.st index 7b827b52..9cab6fac 100644 --- a/src/XML-Parser/DTDEntityConfiguration.class.st +++ b/src/XML-Parser/DTDEntityConfiguration.class.st @@ -16,17 +16,20 @@ Class { { #category : #accessing } DTDEntityConfiguration >> externalEntityResolver [ "uses the caching resolver by default" - ^ externalEntityResolver - ifNil: [externalEntityResolver := DTDExternalEntityResolver default] + + ^ externalEntityResolver ifNil: [ + externalEntityResolver := DTDExternalEntityResolver default ] ] { #category : #accessing } DTDEntityConfiguration >> externalEntityResolver: anExternalEntityResolver [ + externalEntityResolver := anExternalEntityResolver ] { #category : #copying } DTDEntityConfiguration >> postCopy [ + super postCopy. externalEntityResolver diff --git a/src/XML-Parser/DTDEnumerationListParser.class.st b/src/XML-Parser/DTDEnumerationListParser.class.st index 5fc90d6a..a8097928 100644 --- a/src/XML-Parser/DTDEnumerationListParser.class.st +++ b/src/XML-Parser/DTDEnumerationListParser.class.st @@ -17,6 +17,7 @@ DTDEnumerationListParser class >> on: aString [ { #category : #private } DTDEnumerationListParser >> errorDuplicateListValue: aValue [ + XMLValidationException formatSignal: 'Duplicate value "{1}" in list' with: aValue @@ -24,22 +25,26 @@ DTDEnumerationListParser >> errorDuplicateListValue: aValue [ { #category : #private } DTDEnumerationListParser >> listEndOffset [ + ^ 1 "')' size" ] { #category : #private } DTDEnumerationListParser >> listStartOffset [ + ^ 1 "'(' size" ] { #category : #initialization } DTDEnumerationListParser >> on: aString [ + listString := aString ] { #category : #parsing } DTDEnumerationListParser >> parse [ "the tokenizer removes all spaces from lists" + | listStartIndex listEndIndex totalListValues listValues nextListValuesIndex nextValueStartIndex | listStartIndex := 1 + self listStartOffset. diff --git a/src/XML-Parser/DTDExternalEntityLimits.class.st b/src/XML-Parser/DTDExternalEntityLimits.class.st index d409e977..79b2ffdd 100644 --- a/src/XML-Parser/DTDExternalEntityLimits.class.st +++ b/src/XML-Parser/DTDExternalEntityLimits.class.st @@ -31,11 +31,13 @@ DTDExternalEntityLimits class >> defaultMaxExternalEntitySize [ { #category : #accessing } DTDExternalEntityLimits >> externalSubsetReadLimit [ + ^ externalSubsetReadLimit ] { #category : #accessing } DTDExternalEntityLimits >> externalSubsetReadLimit: anInteger [ + externalSubsetReadLimit := anInteger ] @@ -51,26 +53,31 @@ DTDExternalEntityLimits >> initialize [ { #category : #accessing } DTDExternalEntityLimits >> maxExternalEntities [ + ^ maxExternalEntities ] { #category : #accessing } DTDExternalEntityLimits >> maxExternalEntities: anInteger [ + maxExternalEntities := anInteger ] { #category : #accessing } DTDExternalEntityLimits >> maxExternalEntitySize [ + ^ maxExternalEntitySize ] { #category : #accessing } DTDExternalEntityLimits >> maxExternalEntitySize: anInteger [ + maxExternalEntitySize := anInteger ] { #category : #removing } DTDExternalEntityLimits >> removeAll [ + externalSubsetReadLimit := nil. maxExternalEntities := nil. maxExternalEntitySize := nil. @@ -79,10 +86,12 @@ DTDExternalEntityLimits >> removeAll [ { #category : #accessing } DTDExternalEntityLimits >> resolvesLocalFromNonLocal [ + ^ resolvesLocalFromNonLocal ] { #category : #accessing } DTDExternalEntityLimits >> resolvesLocalFromNonLocal: aBoolean [ + resolvesLocalFromNonLocal := aBoolean ] diff --git a/src/XML-Parser/DTDExternalEntityResolver.class.st b/src/XML-Parser/DTDExternalEntityResolver.class.st index b972896b..0dd31cac 100644 --- a/src/XML-Parser/DTDExternalEntityResolver.class.st +++ b/src/XML-Parser/DTDExternalEntityResolver.class.st @@ -84,21 +84,25 @@ DTDExternalEntityResolver >> externalSubsetReadLimit: anInteger [ { #category : #configuring } DTDExternalEntityResolver >> maxExternalEntities [ + ^ self externalEntityLimits maxExternalEntities ] { #category : #configuring } DTDExternalEntityResolver >> maxExternalEntities: anInteger [ + self externalEntityLimits maxExternalEntities: anInteger ] { #category : #configuring } DTDExternalEntityResolver >> maxExternalEntitySize [ + ^ self externalEntityLimits maxExternalEntitySize ] { #category : #configuring } DTDExternalEntityResolver >> maxExternalEntitySize: anInteger [ + self externalEntityLimits maxExternalEntitySize: anInteger ] @@ -112,11 +116,13 @@ DTDExternalEntityResolver >> postCopy [ { #category : #configuring } DTDExternalEntityResolver >> removeLimits [ + self externalEntityLimits removeAll ] { #category : #resolving } DTDExternalEntityResolver >> resolveExternalEntityURI: anXMLURIOrURIString [ + ^ self resolveExternalEntityURI: anXMLURIOrURIString upToLimit: self maxExternalEntitySize @@ -124,6 +130,7 @@ DTDExternalEntityResolver >> resolveExternalEntityURI: anXMLURIOrURIString [ { #category : #resolving } DTDExternalEntityResolver >> resolveExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + | uri | ^ (uri := anXMLURIOrURIString asXMLURI) isLocal @@ -139,6 +146,7 @@ DTDExternalEntityResolver >> resolveExternalEntityURI: anXMLURIOrURIString upToL { #category : #private } DTDExternalEntityResolver >> resolveLocalExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + ^ DTDUndecodedResolvedExternalParsedEntityReplacement rawContents: (anXMLURIOrURIString asXMLFileHandle getUpToLimit: aMaxSize @@ -147,6 +155,7 @@ DTDExternalEntityResolver >> resolveLocalExternalEntityURI: anXMLURIOrURIString { #category : #private } DTDExternalEntityResolver >> resolveNonLocalExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + | response | response := @@ -163,6 +172,7 @@ DTDExternalEntityResolver >> resolveNonLocalExternalEntityURI: anXMLURIOrURIStri { #category : #configuring } DTDExternalEntityResolver >> resolvesLocalFromNonLocal [ + ^ self externalEntityLimits resolvesLocalFromNonLocal ] @@ -176,6 +186,7 @@ DTDExternalEntityResolver >> resolvesLocalFromNonLocal: aBoolean [ { #category : #resolving } DTDExternalEntityResolver >> streamResolveExternalEntityURI: anXMLURIOrURIString [ + ^ self streamResolveExternalEntityURI: anXMLURIOrURIString upToLimit: self maxExternalEntitySize @@ -183,6 +194,7 @@ DTDExternalEntityResolver >> streamResolveExternalEntityURI: anXMLURIOrURIString { #category : #resolving } DTDExternalEntityResolver >> streamResolveExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + | uri | ^ (uri := anXMLURIOrURIString asXMLURI) isLocal @@ -200,6 +212,7 @@ DTDExternalEntityResolver >> streamResolveExternalEntityURI: anXMLURIOrURIString DTDExternalEntityResolver >> streamResolveLocalExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ "return our own decoding adapter on the raw, undecoded stream to avoid looking for any byte-order mark until later" + ^ XMLDecodingReadStreamAdapter nonDecodingOn: (anXMLURIOrURIString asXMLFileHandle streamGetUpToLimit: aMaxSize @@ -208,6 +221,7 @@ DTDExternalEntityResolver >> streamResolveLocalExternalEntityURI: anXMLURIOrURIS { #category : #private } DTDExternalEntityResolver >> streamResolveNonLocalExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + ^ (self resolveNonLocalExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize) readStream diff --git a/src/XML-Parser/DTDExternalEntityResolverLimitingDecorator.class.st b/src/XML-Parser/DTDExternalEntityResolverLimitingDecorator.class.st index f6c49bb1..325f6177 100644 --- a/src/XML-Parser/DTDExternalEntityResolverLimitingDecorator.class.st +++ b/src/XML-Parser/DTDExternalEntityResolverLimitingDecorator.class.st @@ -18,11 +18,13 @@ DTDExternalEntityResolverLimitingDecorator class >> externalEntityResolver: anEx { #category : #converting } DTDExternalEntityResolverLimitingDecorator >> asLimitingExternalEntityResolver [ + ^ self ] { #category : #private } DTDExternalEntityResolverLimitingDecorator >> checkExternalEntityLimit [ + | maxExternalEntities | ((maxExternalEntities := self externalEntityResolver maxExternalEntities) notNil @@ -32,6 +34,7 @@ DTDExternalEntityResolverLimitingDecorator >> checkExternalEntityLimit [ { #category : #private } DTDExternalEntityResolverLimitingDecorator >> erorrExternalEntityLimitExceeded [ + XMLLimitException signal: 'External entity limit exceeded; ', 'use #maxExternalEntities: to change or disable' @@ -39,26 +42,31 @@ DTDExternalEntityResolverLimitingDecorator >> erorrExternalEntityLimitExceeded [ { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> externalEntityLimits [ + ^ self externalEntityResolver externalEntityLimits ] { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> externalEntityLimits: anExternalEntityLimits [ + self externalEntityResolver externalEntityLimits: anExternalEntityLimits ] { #category : #accessing } DTDExternalEntityResolverLimitingDecorator >> externalEntityResolver [ + ^ externalEntityResolver ] { #category : #accessing } DTDExternalEntityResolverLimitingDecorator >> externalEntityResolver: anExternalEntityResolver [ + externalEntityResolver := anExternalEntityResolver ] { #category : #resolving } DTDExternalEntityResolverLimitingDecorator >> externalEntityURIFromPublicID: aPublicID systemID: aSystemID [ + ^ self externalEntityResolver externalEntityURIFromPublicID: aPublicID systemID: aSystemID @@ -66,6 +74,7 @@ DTDExternalEntityResolverLimitingDecorator >> externalEntityURIFromPublicID: aPu { #category : #resolving } DTDExternalEntityResolverLimitingDecorator >> externalEntityURIFromPublicID: aPublicID systemID: aSystemID baseURI: aBaseXMLURIOrURIString [ + ^ self externalEntityResolver externalEntityURIFromPublicID: aPublicID systemID: aSystemID @@ -74,16 +83,19 @@ DTDExternalEntityResolverLimitingDecorator >> externalEntityURIFromPublicID: aPu { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> externalSubsetReadLimit [ + ^ self externalEntityResolver externalSubsetReadLimit ] { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> externalSubsetReadLimit: anInteger [ + self externalEntityResolver externalSubsetReadLimit: anInteger ] { #category : #private } DTDExternalEntityResolverLimitingDecorator >> incrementTotalResolvedExternalEntities [ + totalResolvedExternalEntities := totalResolvedExternalEntities ifNil: [1] @@ -92,26 +104,31 @@ DTDExternalEntityResolverLimitingDecorator >> incrementTotalResolvedExternalEnti { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> maxExternalEntities [ + ^ self externalEntityResolver maxExternalEntities ] { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> maxExternalEntities: anInteger [ + self externalEntityResolver maxExternalEntities: anInteger ] { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> maxExternalEntitySize [ + ^ self externalEntityResolver maxExternalEntitySize ] { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> maxExternalEntitySize: anInteger [ + self externalEntityResolver maxExternalEntitySize: anInteger ] { #category : #printing } DTDExternalEntityResolverLimitingDecorator >> printOn: aStream [ + super printOn: aStream. aStream @@ -122,11 +139,13 @@ DTDExternalEntityResolverLimitingDecorator >> printOn: aStream [ { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> removeLimits [ + self externalEntityResolver removeLimits ] { #category : #resolving } DTDExternalEntityResolverLimitingDecorator >> resolveExternalEntityURI: anXMLURIOrURIString [ + ^ self resolveExternalEntityWith: [ self externalEntityResolver resolveExternalEntityURI: anXMLURIOrURIString] @@ -134,6 +153,7 @@ DTDExternalEntityResolverLimitingDecorator >> resolveExternalEntityURI: anXMLURI { #category : #resolving } DTDExternalEntityResolverLimitingDecorator >> resolveExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + ^ self resolveExternalEntityWith: [ self externalEntityResolver resolveExternalEntityURI: anXMLURIOrURIString @@ -142,6 +162,7 @@ DTDExternalEntityResolverLimitingDecorator >> resolveExternalEntityURI: anXMLURI { #category : #private } DTDExternalEntityResolverLimitingDecorator >> resolveExternalEntityWith: aBlock [ + | result | self checkExternalEntityLimit. @@ -153,16 +174,19 @@ DTDExternalEntityResolverLimitingDecorator >> resolveExternalEntityWith: aBlock { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> resolvesLocalFromNonLocal [ + ^ self externalEntityResolver resolvesLocalFromNonLocal ] { #category : #configuring } DTDExternalEntityResolverLimitingDecorator >> resolvesLocalFromNonLocal: aBoolean [ + self externalEntityResolver resolvesLocalFromNonLocal: aBoolean ] { #category : #resolving } DTDExternalEntityResolverLimitingDecorator >> streamResolveExternalEntityURI: anXMLURIOrURIString [ + ^ self resolveExternalEntityWith: [ self externalEntityResolver streamResolveExternalEntityURI: anXMLURIOrURIString] @@ -170,6 +194,7 @@ DTDExternalEntityResolverLimitingDecorator >> streamResolveExternalEntityURI: an { #category : #resolving } DTDExternalEntityResolverLimitingDecorator >> streamResolveExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + ^ self resolveExternalEntityWith: [ self externalEntityResolver streamResolveExternalEntityURI: anXMLURIOrURIString @@ -178,5 +203,6 @@ DTDExternalEntityResolverLimitingDecorator >> streamResolveExternalEntityURI: an { #category : #accessing } DTDExternalEntityResolverLimitingDecorator >> totalResolvedExternalEntities [ + ^ totalResolvedExternalEntities ifNil: [totalResolvedExternalEntities := 0] ] diff --git a/src/XML-Parser/DTDExternalParameterParsedEntity.class.st b/src/XML-Parser/DTDExternalParameterParsedEntity.class.st index 863beeff..c03126a5 100644 --- a/src/XML-Parser/DTDExternalParameterParsedEntity.class.st +++ b/src/XML-Parser/DTDExternalParameterParsedEntity.class.st @@ -9,5 +9,6 @@ Class { { #category : #testing } DTDExternalParameterParsedEntity >> isParameter [ + ^ true ] diff --git a/src/XML-Parser/DTDExternalParsedEntity.class.st b/src/XML-Parser/DTDExternalParsedEntity.class.st index aa20f71f..ba05b421 100644 --- a/src/XML-Parser/DTDExternalParsedEntity.class.st +++ b/src/XML-Parser/DTDExternalParsedEntity.class.st @@ -27,21 +27,25 @@ DTDExternalParsedEntity class >> name: aName resolver: aResolver publicID: aPubl { #category : #testing } DTDExternalParsedEntity >> hasReplacement [ + ^ self resolvedReplacement notEmpty ] { #category : #testing } DTDExternalParsedEntity >> hasUnresolvedReplacement [ + ^ self unresolvedReplacement notNil ] { #category : #testing } DTDExternalParsedEntity >> isExternal [ + ^ true ] { #category : #printing } DTDExternalParsedEntity >> printNameOn: aStream [ + aStream nextPut: ${; nextPutAll: self uri; @@ -51,43 +55,51 @@ DTDExternalParsedEntity >> printNameOn: aStream [ { #category : #accessing } DTDExternalParsedEntity >> replacement [ + ^ self resolvedReplacement contents ] { #category : #accessing } DTDExternalParsedEntity >> replacementStream [ + ^ self resolvedReplacement readStream ] { #category : #resolving } DTDExternalParsedEntity >> resolveUnresolvedReplacement [ - self hasUnresolvedReplacement - ifTrue: [self unresolvedReplacement resolveForExternalEntity: self] + + self hasUnresolvedReplacement ifTrue: [ + self unresolvedReplacement resolveForExternalEntity: self ] ] { #category : #accessing } DTDExternalParsedEntity >> resolvedReplacement [ + self resolveUnresolvedReplacement. ^ resolvedReplacement ] { #category : #accessing } DTDExternalParsedEntity >> resolvedReplacement: aResolvedReplacement [ + resolvedReplacement := aResolvedReplacement ] { #category : #initialization } DTDExternalParsedEntity >> setName: aName unresolvedReplacement: anUnresolvedReplacement [ + name := aName. unresolvedReplacement := anUnresolvedReplacement ] { #category : #accessing } DTDExternalParsedEntity >> unresolvedReplacement [ + ^ unresolvedReplacement ] { #category : #accessing } DTDExternalParsedEntity >> unresolvedReplacement: anUnresolvedReplacement [ + unresolvedReplacement := anUnresolvedReplacement ] diff --git a/src/XML-Parser/DTDInternalParameterParsedEntity.class.st b/src/XML-Parser/DTDInternalParameterParsedEntity.class.st index 9cb876d0..5dc8ebe1 100644 --- a/src/XML-Parser/DTDInternalParameterParsedEntity.class.st +++ b/src/XML-Parser/DTDInternalParameterParsedEntity.class.st @@ -9,5 +9,6 @@ Class { { #category : #testing } DTDInternalParameterParsedEntity >> isParameter [ + ^ true ] diff --git a/src/XML-Parser/DTDInternalParsedEntity.class.st b/src/XML-Parser/DTDInternalParsedEntity.class.st index fc323804..d786225e 100644 --- a/src/XML-Parser/DTDInternalParsedEntity.class.st +++ b/src/XML-Parser/DTDInternalParsedEntity.class.st @@ -28,26 +28,31 @@ DTDInternalParsedEntity class >> name: aName replacement: aReplacementString uri { #category : #testing } DTDInternalParsedEntity >> hasReplacement [ + ^ self replacement notEmpty ] { #category : #accessing } DTDInternalParsedEntity >> replacement [ - ^ replacement ifNil: [replacement := ''] + + ^ replacement ifNil: [ replacement := '' ] ] { #category : #accessing } DTDInternalParsedEntity >> replacement: aReplacementString [ + replacement := aReplacementString ] { #category : #accessing } DTDInternalParsedEntity >> replacementStream [ + ^ self replacement readStream ] { #category : #initialization } DTDInternalParsedEntity >> setName: aName replacement: aReplacementString uri: aURIString [ + name := aName. replacement := aReplacementString. uri := aURIString diff --git a/src/XML-Parser/DTDLiteralContentModelParser.class.st b/src/XML-Parser/DTDLiteralContentModelParser.class.st index 40209f97..7da1d023 100644 --- a/src/XML-Parser/DTDLiteralContentModelParser.class.st +++ b/src/XML-Parser/DTDLiteralContentModelParser.class.st @@ -10,6 +10,7 @@ Class { { #category : #parsing } DTDLiteralContentModelParser >> parse [ "either ANY or EMPTY" + (contentModel at: 1) == $A ifTrue: [^ XMLAnyElementValidator element: element] ifFalse: [^ XMLEmptyElementValidator element: element] diff --git a/src/XML-Parser/DTDMixedContentEnumerationListParser.class.st b/src/XML-Parser/DTDMixedContentEnumerationListParser.class.st index e51c8d77..3604c753 100644 --- a/src/XML-Parser/DTDMixedContentEnumerationListParser.class.st +++ b/src/XML-Parser/DTDMixedContentEnumerationListParser.class.st @@ -9,7 +9,8 @@ Class { { #category : #private } DTDMixedContentEnumerationListParser >> listEndOffset [ + ^ listString last == $* - ifTrue: [2] "')*' size" - ifFalse: [1] "')' size" + ifTrue: [ 2 "')*' size"] + ifFalse: [ 1 "')' size" ] ] diff --git a/src/XML-Parser/DTDNotation.class.st b/src/XML-Parser/DTDNotation.class.st index 33695157..29b48544 100644 --- a/src/XML-Parser/DTDNotation.class.st +++ b/src/XML-Parser/DTDNotation.class.st @@ -30,26 +30,31 @@ DTDNotation class >> name: aName publicID: aPublicID systemID: aSystemID [ { #category : #accessing } DTDNotation >> name [ - ^ name ifNil: [name := ''] + + ^ name ifNil: [ name := '' ] ] { #category : #accessing } DTDNotation >> name: aName [ + name := aName ] { #category : #accessing } DTDNotation >> publicID [ - ^ publicID ifNil: [publicID := ''] + + ^ publicID ifNil: [ publicID := '' ] ] { #category : #accessing } DTDNotation >> publicID: aPublicID [ + publicID := aPublicID ] { #category : #initialization } DTDNotation >> setName: aName publicID: aPublicID systemID: aSystemID [ + name := aName. publicID := aPublicID. systemID := aSystemID @@ -57,10 +62,12 @@ DTDNotation >> setName: aName publicID: aPublicID systemID: aSystemID [ { #category : #accessing } DTDNotation >> systemID [ - ^ systemID ifNil: [systemID := ''] + + ^ systemID ifNil: [ systemID := '' ] ] { #category : #accessing } DTDNotation >> systemID: aSystemID [ + systemID := aSystemID ] diff --git a/src/XML-Parser/DTDNotationEnumerationListParser.class.st b/src/XML-Parser/DTDNotationEnumerationListParser.class.st index 97958fed..10972b41 100644 --- a/src/XML-Parser/DTDNotationEnumerationListParser.class.st +++ b/src/XML-Parser/DTDNotationEnumerationListParser.class.st @@ -9,5 +9,6 @@ Class { { #category : #private } DTDNotationEnumerationListParser >> listStartOffset [ + ^ 10 "'NOTATION (' size" ] diff --git a/src/XML-Parser/DTDParsedEntity.class.st b/src/XML-Parser/DTDParsedEntity.class.st index ea99463f..6e797975 100644 --- a/src/XML-Parser/DTDParsedEntity.class.st +++ b/src/XML-Parser/DTDParsedEntity.class.st @@ -9,22 +9,26 @@ Class { { #category : #converting } DTDParsedEntity >> asPushedBackEntity [ + ^ self isParameter - ifTrue: [XMLPushedBackParameterEntity entity: self] - ifFalse: [XMLPushedBackGeneralEntity entity: self] + ifTrue: [ XMLPushedBackParameterEntity entity: self ] + ifFalse: [ XMLPushedBackGeneralEntity entity: self ] ] { #category : #testing } DTDParsedEntity >> hasReplacement [ + self subclassResponsibility ] { #category : #accessing } DTDParsedEntity >> replacement [ + self subclassResponsibility ] { #category : #accessing } DTDParsedEntity >> replacementStream [ + self subclassResponsibility ] diff --git a/src/XML-Parser/DTDResolvedExternalParsedEntityReplacement.class.st b/src/XML-Parser/DTDResolvedExternalParsedEntityReplacement.class.st index 6922891f..ac5da409 100644 --- a/src/XML-Parser/DTDResolvedExternalParsedEntityReplacement.class.st +++ b/src/XML-Parser/DTDResolvedExternalParsedEntityReplacement.class.st @@ -9,25 +9,30 @@ Class { { #category : #converting } DTDResolvedExternalParsedEntityReplacement >> asString [ + ^ self contents ] { #category : #accessing } DTDResolvedExternalParsedEntityReplacement >> contents [ + self subclassResponsibility ] { #category : #testing } DTDResolvedExternalParsedEntityReplacement >> isEmpty [ + self subclassResponsibility ] { #category : #testing } DTDResolvedExternalParsedEntityReplacement >> notEmpty [ + ^ self isEmpty not ] { #category : #accessing } DTDResolvedExternalParsedEntityReplacement >> readStream [ + self subclassResponsibility ] diff --git a/src/XML-Parser/DTDStaticExternalEntityResolver.class.st b/src/XML-Parser/DTDStaticExternalEntityResolver.class.st index c3c09a9b..c43967c5 100644 --- a/src/XML-Parser/DTDStaticExternalEntityResolver.class.st +++ b/src/XML-Parser/DTDStaticExternalEntityResolver.class.st @@ -17,6 +17,7 @@ DTDStaticExternalEntityResolver class >> externalEntities: anAssociationCollecti { #category : #private } DTDStaticExternalEntityResolver >> errorMaxExternalEntitySize: aMaxSize exceededByURI: anXMLURIOrURIString [ + XMLLimitException formatSignal: 'Entity exceeds max size of {1} bytes: {2}' with: aMaxSize @@ -25,6 +26,7 @@ DTDStaticExternalEntityResolver >> errorMaxExternalEntitySize: aMaxSize exceeded { #category : #private } DTDStaticExternalEntityResolver >> errorUnresolvableExternalEntityURI: anXMLURIOrURIString [ + XMLParserException formatSignal: 'Unresolvable external entity URI: {1}' with: anXMLURIOrURIString asString @@ -32,11 +34,13 @@ DTDStaticExternalEntityResolver >> errorUnresolvableExternalEntityURI: anXMLURIO { #category : #accessing } DTDStaticExternalEntityResolver >> externalEntities [ + ^ externalEntities ifNil: [externalEntities := Dictionary new] ] { #category : #accessing } DTDStaticExternalEntityResolver >> externalEntities: anAssociationCollection [ + self hasExternalEntities ifTrue: [self removeExternalEntities]. anAssociationCollection associationsDo: [:each | @@ -47,6 +51,7 @@ DTDStaticExternalEntityResolver >> externalEntities: anAssociationCollection [ { #category : #accessing } DTDStaticExternalEntityResolver >> externalEntityAtURI: anXMLURIOrURIString [ + ^ self externalEntityAtURI: anXMLURIOrURIString asXMLURI ifAbsent: [''] @@ -54,6 +59,7 @@ DTDStaticExternalEntityResolver >> externalEntityAtURI: anXMLURIOrURIString [ { #category : #accessing } DTDStaticExternalEntityResolver >> externalEntityAtURI: anXMLURIOrURIString ifAbsent: aBlock [ + ^ self externalEntities at: anXMLURIOrURIString asXMLURI ifAbsent: aBlock @@ -61,6 +67,7 @@ DTDStaticExternalEntityResolver >> externalEntityAtURI: anXMLURIOrURIString ifAb { #category : #accessing } DTDStaticExternalEntityResolver >> externalEntityAtURI: anXMLURIOrURIString ifAbsentPut: aBlock [ + ^ self externalEntities at: anXMLURIOrURIString asXMLURI ifAbsentPut: aBlock @@ -68,6 +75,7 @@ DTDStaticExternalEntityResolver >> externalEntityAtURI: anXMLURIOrURIString ifAb { #category : #accessing } DTDStaticExternalEntityResolver >> externalEntityAtURI: anXMLURIOrURIString put: aReplacement [ + ^ self externalEntities at: anXMLURIOrURIString asXMLURI put: aReplacement @@ -75,16 +83,19 @@ DTDStaticExternalEntityResolver >> externalEntityAtURI: anXMLURIOrURIString put: { #category : #testing } DTDStaticExternalEntityResolver >> hasExternalEntities [ + ^ self externalEntities notEmpty ] { #category : #testing } DTDStaticExternalEntityResolver >> includesExternalEntityURI: anXMLURIOrURIString [ + ^ self externalEntities includesKey: anXMLURIOrURIString asXMLURI ] { #category : #copying } DTDStaticExternalEntityResolver >> postCopy [ + super postCopy. externalEntities @@ -93,16 +104,19 @@ DTDStaticExternalEntityResolver >> postCopy [ { #category : #removing } DTDStaticExternalEntityResolver >> removeExternalEntities [ + self externalEntities removeAll ] { #category : #removing } DTDStaticExternalEntityResolver >> removeExternalEntityURI: anXMLURIOrURIString [ + ^ self externalEntities removeKey: anXMLURIOrURIString asXMLURI ] { #category : #removing } DTDStaticExternalEntityResolver >> removeExternalEntityURI: anXMLURIOrURIString ifAbsent: aBlock [ + ^ self externalEntities removeKey: anXMLURIOrURIString asXMLURI ifAbsent: aBlock @@ -110,6 +124,7 @@ DTDStaticExternalEntityResolver >> removeExternalEntityURI: anXMLURIOrURIString { #category : #resolving } DTDStaticExternalEntityResolver >> resolveExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + | replacement | replacement := @@ -130,6 +145,7 @@ DTDStaticExternalEntityResolver >> resolveExternalEntityURI: anXMLURIOrURIString { #category : #resolving } DTDStaticExternalEntityResolver >> streamResolveExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize [ + ^ (self resolveExternalEntityURI: anXMLURIOrURIString upToLimit: aMaxSize) readStream diff --git a/src/XML-Parser/DTDUnparsedEntity.class.st b/src/XML-Parser/DTDUnparsedEntity.class.st index 074269ae..e5a404c2 100644 --- a/src/XML-Parser/DTDUnparsedEntity.class.st +++ b/src/XML-Parser/DTDUnparsedEntity.class.st @@ -23,31 +23,37 @@ DTDUnparsedEntity class >> name: aName publicID: aPublicID systemID: aSystemID n { #category : #testing } DTDUnparsedEntity >> isUnparsed [ + ^ true ] { #category : #accessing } DTDUnparsedEntity >> ndata [ - ^ ndata ifNil: [ndata := ''] + + ^ ndata ifNil: [ ndata := '' ] ] { #category : #accessing } DTDUnparsedEntity >> ndata: aNotationName [ + ndata := aNotationName ] { #category : #accessing } DTDUnparsedEntity >> publicID [ - ^ publicID ifNil: [publicID := ''] + + ^ publicID ifNil: [ publicID := '' ] ] { #category : #accessing } DTDUnparsedEntity >> publicID: aPublicID [ + publicID := aPublicID ] { #category : #initialization } DTDUnparsedEntity >> setName: aName publicID: aPublicID systemID: aSystemID ndata: aNotationName [ + name := aName. publicID := aPublicID. systemID := aSystemID. @@ -56,10 +62,12 @@ DTDUnparsedEntity >> setName: aName publicID: aPublicID systemID: aSystemID ndat { #category : #accessing } DTDUnparsedEntity >> systemID [ - ^ systemID ifNil: [systemID := ''] + + ^ systemID ifNil: [ systemID := '' ] ] { #category : #accessing } DTDUnparsedEntity >> systemID: aSystemID [ + systemID := aSystemID ] diff --git a/src/XML-Parser/DTDUnresolvableExternalParameterParsedEntity.class.st b/src/XML-Parser/DTDUnresolvableExternalParameterParsedEntity.class.st index af636bad..7d9f15ee 100644 --- a/src/XML-Parser/DTDUnresolvableExternalParameterParsedEntity.class.st +++ b/src/XML-Parser/DTDUnresolvableExternalParameterParsedEntity.class.st @@ -9,5 +9,6 @@ Class { { #category : #testing } DTDUnresolvableExternalParameterParsedEntity >> isParameter [ + ^ true ] diff --git a/src/XML-Parser/DTDUnresolvableExternalParsedEntity.class.st b/src/XML-Parser/DTDUnresolvableExternalParsedEntity.class.st index fe8ea2ce..b8ba0bcb 100644 --- a/src/XML-Parser/DTDUnresolvableExternalParsedEntity.class.st +++ b/src/XML-Parser/DTDUnresolvableExternalParsedEntity.class.st @@ -9,30 +9,35 @@ Class { { #category : #private } DTDUnresolvableExternalParsedEntity >> errorUnresolvableExternalEntity [ + XMLParserException formatSignal: - 'External entity {1} can''t be resolved unless resolution is ', - 'enabled; use #resolvesExternalEntityReferences: before parsing ', - 'to enable' + 'External entity {1} can''t be resolved unless resolution is ' + , 'enabled; use #resolvesExternalEntityReferences: before parsing ' + , 'to enable' with: self asReference ] { #category : #testing } DTDUnresolvableExternalParsedEntity >> hasReplacement [ + ^ true ] { #category : #testing } DTDUnresolvableExternalParsedEntity >> isExternal [ + ^ true ] { #category : #accessing } DTDUnresolvableExternalParsedEntity >> replacement [ + self errorUnresolvableExternalEntity ] { #category : #accessing } DTDUnresolvableExternalParsedEntity >> replacementStream [ + self errorUnresolvableExternalEntity ] diff --git a/src/XML-Parser/ManifestXMLParser.class.st b/src/XML-Parser/ManifestXMLParser.class.st new file mode 100644 index 00000000..de2b7930 --- /dev/null +++ b/src/XML-Parser/ManifestXMLParser.class.st @@ -0,0 +1,29 @@ +" +Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser +" +Class { + #name : #ManifestXMLParser, + #superclass : #PackageManifest, + #category : #'XML-Parser-Manifest' +} + +{ #category : #'code-critics' } +ManifestXMLParser class >> ruleBadMessageRule2V1FalsePositive [ + + + ^ #(#(#(#RGMethodDefinition #(#DTDElementContentModelParser #applyOperator: #false)) #'2023-10-26T00:29:04.983936+02:00') ) +] + +{ #category : #'code-critics' } +ManifestXMLParser class >> ruleExcessiveArgumentsRuleV1FalsePositive [ + + + ^ #(#(#(#RGMethodDefinition #(#DTDDoctypeDefinition #addExternalParameterEntity:resolver:publicID:systemID:baseURI: #false)) #'2023-10-26T00:32:13.375878+02:00') #(#(#RGMethodDefinition #(#DTDDoctypeDefinition #addStandaloneExternalExternalGeneralEntity:resolver:publicID:systemID:baseURI: #false)) #'2023-10-26T00:32:40.310435+02:00') #(#(#RGMethodDefinition #(#DTDDoctypeDefinition #addStandaloneExternalValidatorForAttributeIn:named:type:defaultPragma:defaultValue: #false)) #'2023-10-26T00:33:20.394652+02:00') #(#(#RGMethodDefinition #(#DTDDoctypeDefinition #addValidatorForAttributeIn:named:type:defaultPragma:defaultValue: #false)) #'2023-10-26T00:34:18.241313+02:00') ) +] + +{ #category : #'code-critics' } +ManifestXMLParser class >> ruleLiteralArrayContainsSuspiciousTrueFalseOrNilRuleV1FalsePositive [ + + + ^ #(#(#(#RGMetaclassDefinition #(#'ManifestXMLParser class' #ManifestXMLParser)) #'2023-10-26T01:11:45.317214+02:00') ) +]