Skip to content

Commit a8b3564

Browse files
committed
update docs
1 parent ca273dc commit a8b3564

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

docs/v4, v5/2.XMLparseOptions.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,16 @@ If your XML has NCR(Numeric Character Reference) in XML document then the respon
382382

383383
You can read more detail for advance handling in [@nodable/entities](https://github.com/nodable/val-parsers/blob/main/Entity/docs/EntityDecoder.md) configuration.
384384

385-
> ⚠️ It is advisable to use the `postCheck` function to safely handle malicious data.
385+
386+
### Note
387+
- ⚠️ It is advisable to use the `postCheck` function to safely handle malicious data.
388+
- FXP overrides `onInputEntity` to check entity value if marked unsafe by [is-unsafe](library). You may override for better protection of your project specific security.
389+
```js
390+
onInputEntity: (name, value) =>
391+
isUnsafe(value, [VALID_CONTEXTS.HTML, VALID_CONTEXTS.XML])
392+
? ENTITY_ACTION.BLOCK : ENTITY_ACTION.ALLOW
393+
```
394+
- 2 separate entities togehter can form dangerous property name.
386395

387396

388397
## ignoreAttributes
@@ -1321,6 +1330,7 @@ Output
13211330
}
13221331
```
13231332

1333+
⚠️ You can use 'is-unsafe' library to check if doctype entities or external entities combination form any dangerous string which is not safe for your data/document.
13241334

13251335
## textNodeName
13261336
Text value of a tag is parsed to `#text` property by default. You can always change this.
@@ -1455,6 +1465,7 @@ updateTag: (tagName, jPathOrMatcher, attrs) => {
14551465
}
14561466
```
14571467

1468+
> ⚠️ You should ensure that any change in tagname or attributes don't form a dangerous property.
14581469
14591470
**With jPath: true (default):**
14601471
```js

src/xmlparser/OrderedObjParser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export default class OrderedObjParser {
103103
},
104104
// onExternalEntity: (name, value) => isUnsafe(value) ? 'block' : 'allow',
105105
onInputEntity: (name, value) =>
106+
//TODO: VALID_CONTEXTS.HTML should be set only if this.options.htmlEntities
106107
isUnsafe(value, [VALID_CONTEXTS.HTML, VALID_CONTEXTS.XML])
107108
? ENTITY_ACTION.BLOCK : ENTITY_ACTION.ALLOW,
108109

0 commit comments

Comments
 (0)