mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 04:16:17 +01:00 
			
		
		
		
	validate/clean inverse relation name in promoted attr definition
This commit is contained in:
		@@ -626,7 +626,9 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
                props.push('precision=' + this.$inputNumberPrecision.val());
 | 
					                props.push('precision=' + this.$inputNumberPrecision.val());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if (this.attrType === 'relation-definition' && this.$inputInverseRelation.val().trim().length > 0) {
 | 
					        } else if (this.attrType === 'relation-definition' && this.$inputInverseRelation.val().trim().length > 0) {
 | 
				
			||||||
            props.push("inverse=" + this.$inputInverseRelation.val());
 | 
					            const inverseRelationName = this.$inputInverseRelation.val();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            props.push("inverse=" + utils.filterAttributeName(inverseRelationName));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$rowNumberPrecision.toggle(
 | 
					        this.$rowNumberPrecision.toggle(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,7 @@ function parse(value) {
 | 
				
			|||||||
        else if (token.startsWith('inverse')) {
 | 
					        else if (token.startsWith('inverse')) {
 | 
				
			||||||
            const chunks = token.split('=');
 | 
					            const chunks = token.split('=');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            defObj.inverseRelation = chunks[1];
 | 
					            defObj.inverseRelation = chunks[1].replace(/[^\p{L}\p{N}_:]/ug, "")
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            console.log("Unrecognized attribute definition token:", token);
 | 
					            console.log("Unrecognized attribute definition token:", token);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -298,6 +298,10 @@ function normalize(str) {
 | 
				
			|||||||
    return removeDiacritic(str).toLowerCase();
 | 
					    return removeDiacritic(str).toLowerCase();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function filterAttributeName(name) {
 | 
				
			||||||
 | 
					    return name.replace(/[^\p{L}\p{N}_:]/ug, "");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
    randomSecureToken,
 | 
					    randomSecureToken,
 | 
				
			||||||
    randomString,
 | 
					    randomString,
 | 
				
			||||||
@@ -331,5 +335,6 @@ module.exports = {
 | 
				
			|||||||
    timeLimit,
 | 
					    timeLimit,
 | 
				
			||||||
    deferred,
 | 
					    deferred,
 | 
				
			||||||
    removeDiacritic,
 | 
					    removeDiacritic,
 | 
				
			||||||
    normalize
 | 
					    normalize,
 | 
				
			||||||
 | 
					    filterAttributeName
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user