fast-xml-validator 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-xml-validator",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Validate XML for Syntax and Business rules without C/C++ based libraries",
5
5
  "main": "./lib/fxv.cjs",
6
6
  "type": "module",
package/src/validator.js CHANGED
@@ -387,10 +387,15 @@ function validateAttributeString(attrStr, options, xmlVersion) {
387
387
  return { err: { code: 'InvalidAttr', msg: "Attribute '" + attrName + "' is an invalid name.", line: getPositionFromMatch(matches[i]) } };
388
388
  }
389
389
 
390
- // xmlns="" (undeclaring the default namespace) is valid in XML 1.1
391
- // only. Emit a clear error rather than silently accepting it.
392
- if (attrName === 'xmlns' && matches[i][6] === '') {
393
- return { err: { code: 'InvalidAttr', msg: 'Undeclaring the default namespace with xmlns="" is only permitted in XML 1.1 documents.', line: getPositionFromMatch(matches[i]) } };
390
+ // xmlns="" (undeclaring the prefixed namespace) is valid in XML 1.1
391
+ if (attrName.startsWith('xmlns:') && matches[i][6] === '' && xmlVersion === '1.0') {
392
+ return {
393
+ err: {
394
+ code: 'InvalidAttr',
395
+ msg: `Undeclaring the prefixed namespace ${attrName}="" is only permitted in XML 1.1 documents.`,
396
+ line: getPositionFromMatch(matches[i])
397
+ }
398
+ };
394
399
  }
395
400
 
396
401
  if (!Object.prototype.hasOwnProperty.call(attrNames, attrName)) {