MCPcopy Create free account
hub / github.com/NaturalIntelligence/fast-xml-parser / validatePropertyName

Function validatePropertyName

src/xmlparser/OptionsBuilder.js:67–84  ·  view source on GitHub ↗

* Validates that a property name is safe to use * @param {string} propertyName - The property name to validate * @param {string} optionName - The option field name (for error message) * @throws {Error} If property name is dangerous

(propertyName, optionName)

Source from the content-addressed store, hash-verified

65 * @throws {Error} If property name is dangerous
66 */
67function validatePropertyName(propertyName, optionName) {
68 if (typeof propertyName !== 'string') {
69 return; // Only validate string property names
70 }
71
72 const normalized = propertyName.toLowerCase();
73 if (DANGEROUS_PROPERTY_NAMES.some(dangerous => normalized === dangerous.toLowerCase())) {
74 throw new Error(
75 `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
76 );
77 }
78
79 if (criticalProperties.some(dangerous => normalized === dangerous.toLowerCase())) {
80 throw new Error(
81 `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
82 );
83 }
84}
85
86/**
87 * Normalizes processEntities option for backward compatibility

Callers 1

buildOptionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected