@@ -119,7 +119,7 @@ public void characters(XMLString text, Augmentations augs) throws XNIException {
119
119
}
120
120
121
121
private static final Pattern conditionalDirectives =
122
- Pattern .compile ("<?!?\\ [\\ s*(?:end)?if[^]]*\\ ]>?" );
122
+ Pattern .compile ("<?!?\\ [\\ s*(?:end)?if[^]]*\\ ]>?" );
123
123
124
124
public void comment (XMLString text , Augmentations augs ) throws XNIException {
125
125
@@ -135,12 +135,12 @@ public void comment(XMLString text, Augmentations augs) throws XNIException {
135
135
}
136
136
137
137
public void doctypeDecl (String root , String publicId , String systemId , Augmentations augs )
138
- throws XNIException {
138
+ throws XNIException {
139
139
// user supplied doctypes are ignored
140
140
}
141
141
142
142
public void emptyElement (QName element , XMLAttributes attributes , Augmentations augs )
143
- throws XNIException {
143
+ throws XNIException {
144
144
this .startElement (element , attributes , augs );
145
145
this .endElement (element , augs );
146
146
}
@@ -202,8 +202,8 @@ public void endElement(QName element, Augmentations augs) throws XNIException {
202
202
// if the CSS is unscannable, we report the error, but skip the
203
203
// style element
204
204
addError (
205
- ErrorMessageUtil .ERROR_CSS_TAG_MALFORMED ,
206
- new Object [] {HTMLEntityEncoder .htmlEntityEncode (cssContent .toString ())});
205
+ ErrorMessageUtil .ERROR_CSS_TAG_MALFORMED ,
206
+ new Object [] {HTMLEntityEncoder .htmlEntityEncode (cssContent .toString ())});
207
207
} finally {
208
208
// reset the string buffer to allow fresh recording of next
209
209
// style tag
@@ -225,7 +225,7 @@ private CssScanner makeCssScanner() {
225
225
}
226
226
227
227
public void processingInstruction (String target , XMLString data , Augmentations augs )
228
- throws XNIException {
228
+ throws XNIException {
229
229
// processing instructions are being removed
230
230
}
231
231
@@ -240,7 +240,7 @@ public void endCDATA(Augmentations augs) throws XNIException {
240
240
}
241
241
242
242
public void startElement (QName element , XMLAttributes attributes , Augmentations augs )
243
- throws XNIException {
243
+ throws XNIException {
244
244
// see if we have a policy for this tag.
245
245
String tagNameLowerCase = element .localpart .toLowerCase ();
246
246
Tag tag = policy .getTagByLowercaseName (tagNameLowerCase );
@@ -274,19 +274,19 @@ public void startElement(QName element, XMLAttributes attributes, Augmentations
274
274
// we also remove all child elements of a style element
275
275
this .operations .push (Ops .REMOVE );
276
276
} else if ((tag == null && policy .isEncodeUnknownTag ())
277
- || (tag != null && tag .isAction (Policy .ACTION_ENCODE ))) {
277
+ || (tag != null && tag .isAction (Policy .ACTION_ENCODE ))) {
278
278
String name = "<" + element .localpart + ">" ;
279
279
super .characters (new XMLString (name .toCharArray (), 0 , name .length ()), augs );
280
280
this .operations .push (Ops .ENCODE );
281
281
} else if (tag == null ) {
282
282
addError (
283
- ErrorMessageUtil .ERROR_TAG_NOT_IN_POLICY ,
284
- new Object [] {HTMLEntityEncoder .htmlEntityEncode (element .localpart )});
283
+ ErrorMessageUtil .ERROR_TAG_NOT_IN_POLICY ,
284
+ new Object [] {HTMLEntityEncoder .htmlEntityEncode (element .localpart )});
285
285
this .operations .push (Ops .FILTER );
286
286
} else if (tag .isAction (Policy .ACTION_FILTER )) {
287
287
addError (
288
- ErrorMessageUtil .ERROR_TAG_FILTERED ,
289
- new Object [] {HTMLEntityEncoder .htmlEntityEncode (element .localpart )});
288
+ ErrorMessageUtil .ERROR_TAG_FILTERED ,
289
+ new Object [] {HTMLEntityEncoder .htmlEntityEncode (element .localpart )});
290
290
this .operations .push (Ops .FILTER );
291
291
} else if (tag .isAction ("validate" )) {
292
292
@@ -319,14 +319,14 @@ public void startElement(QName element, XMLAttributes attributes, Augmentations
319
319
errorMessages .addAll (cr .getErrorMessages ());
320
320
} catch (ScanException e ) {
321
321
addError (
322
- ErrorMessageUtil .ERROR_CSS_ATTRIBUTE_MALFORMED ,
323
- new Object [] {element .localpart , HTMLEntityEncoder .htmlEntityEncode (value )});
322
+ ErrorMessageUtil .ERROR_CSS_ATTRIBUTE_MALFORMED ,
323
+ new Object [] {element .localpart , HTMLEntityEncoder .htmlEntityEncode (value )});
324
324
}
325
325
} else if (attribute != null ) {
326
326
// validate the values against the policy
327
327
boolean isValid = false ;
328
328
if (attribute .containsAllowedValue (value .toLowerCase ())
329
- || attribute .matchesAllowedExpression (value )) {
329
+ || attribute .matchesAllowedExpression (value )) {
330
330
int attrIndex ;
331
331
if ((attrIndex = validattributes .getIndex (name )) > 0 ) {
332
332
// If attribute is repeated, use last value.
@@ -342,46 +342,46 @@ public void startElement(QName element, XMLAttributes attributes, Augmentations
342
342
if (!isValid && "removeTag" .equals (attribute .getOnInvalid ())) {
343
343
344
344
addError (
345
- ErrorMessageUtil .ERROR_ATTRIBUTE_INVALID_REMOVED ,
346
- new Object [] {
347
- tag .getName (),
348
- HTMLEntityEncoder .htmlEntityEncode (name ),
349
- HTMLEntityEncoder .htmlEntityEncode (value )
350
- });
345
+ ErrorMessageUtil .ERROR_ATTRIBUTE_INVALID_REMOVED ,
346
+ new Object [] {
347
+ tag .getName (),
348
+ HTMLEntityEncoder .htmlEntityEncode (name ),
349
+ HTMLEntityEncoder .htmlEntityEncode (value )
350
+ });
351
351
352
352
removeTag = true ;
353
353
354
354
} else if (!isValid
355
- && ("filterTag" .equals (attribute .getOnInvalid ()) || masqueradingParam )) {
355
+ && ("filterTag" .equals (attribute .getOnInvalid ()) || masqueradingParam )) {
356
356
357
357
addError (
358
- ErrorMessageUtil .ERROR_ATTRIBUTE_CAUSE_FILTER ,
359
- new Object [] {
360
- tag .getName (),
361
- HTMLEntityEncoder .htmlEntityEncode (name ),
362
- HTMLEntityEncoder .htmlEntityEncode (value )
363
- });
358
+ ErrorMessageUtil .ERROR_ATTRIBUTE_CAUSE_FILTER ,
359
+ new Object [] {
360
+ tag .getName (),
361
+ HTMLEntityEncoder .htmlEntityEncode (name ),
362
+ HTMLEntityEncoder .htmlEntityEncode (value )
363
+ });
364
364
365
365
filterTag = true ;
366
366
367
367
} else if (!isValid ) {
368
368
addError (
369
- ErrorMessageUtil .ERROR_ATTRIBUTE_INVALID ,
370
- new Object [] {
371
- tag .getName (),
372
- HTMLEntityEncoder .htmlEntityEncode (name ),
373
- HTMLEntityEncoder .htmlEntityEncode (value )
374
- });
369
+ ErrorMessageUtil .ERROR_ATTRIBUTE_INVALID ,
370
+ new Object [] {
371
+ tag .getName (),
372
+ HTMLEntityEncoder .htmlEntityEncode (name ),
373
+ HTMLEntityEncoder .htmlEntityEncode (value )
374
+ });
375
375
}
376
376
377
377
} else { // attribute == null
378
378
addError (
379
- ErrorMessageUtil .ERROR_ATTRIBUTE_NOT_IN_POLICY ,
380
- new Object [] {
381
- element .localpart ,
382
- HTMLEntityEncoder .htmlEntityEncode (name ),
383
- HTMLEntityEncoder .htmlEntityEncode (value )
384
- });
379
+ ErrorMessageUtil .ERROR_ATTRIBUTE_NOT_IN_POLICY ,
380
+ new Object [] {
381
+ element .localpart ,
382
+ HTMLEntityEncoder .htmlEntityEncode (name ),
383
+ HTMLEntityEncoder .htmlEntityEncode (value )
384
+ });
385
385
386
386
if (masqueradingParam ) {
387
387
filterTag = true ;
@@ -414,14 +414,14 @@ public void startElement(QName element, XMLAttributes attributes, Augmentations
414
414
if (currentRelValue != null ) {
415
415
Attribute attribute = tag .getAttributeByName ("rel" );
416
416
if (attribute != null
417
- && !(attribute .containsAllowedValue (currentRelValue )
417
+ && !(attribute .containsAllowedValue (currentRelValue )
418
418
|| attribute .matchesAllowedExpression (currentRelValue ))) {
419
419
currentRelValue = "" ;
420
420
}
421
421
}
422
422
String relValue =
423
- Attribute .mergeRelValuesInAnchor (
424
- addNofollow , addNoopenerAndNoreferrer , currentRelValue );
423
+ Attribute .mergeRelValuesInAnchor (
424
+ addNofollow , addNoopenerAndNoreferrer , currentRelValue );
425
425
if (!relValue .isEmpty ()) {
426
426
int relIndex ;
427
427
if ((relIndex = validattributes .getIndex ("rel" )) > 0 ) {
@@ -446,8 +446,8 @@ public void startElement(QName element, XMLAttributes attributes, Augmentations
446
446
} else {
447
447
// no options left, so the tag will be removed
448
448
addError (
449
- ErrorMessageUtil .ERROR_TAG_DISALLOWED ,
450
- new Object [] {HTMLEntityEncoder .htmlEntityEncode (element .localpart )});
449
+ ErrorMessageUtil .ERROR_TAG_DISALLOWED ,
450
+ new Object [] {HTMLEntityEncoder .htmlEntityEncode (element .localpart )});
451
451
this .operations .push (Ops .REMOVE );
452
452
}
453
453
// now we know exactly what to do, let's do it
0 commit comments