mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-06-26 15:12:52 +00:00
Prevented generation of illegal elements
Previously, text like <-> would try to generate an element with an illegal name, causing a JS error
This commit is contained in:
parent
a9f2a24ace
commit
d5f09a4608
@ -379,7 +379,7 @@ exports.findNextTag = function(source,pos,options) {
|
|||||||
// Try to parse the candidate as a tag
|
// Try to parse the candidate as a tag
|
||||||
var tag = this.parseTag(source,match.index,options);
|
var tag = this.parseTag(source,match.index,options);
|
||||||
// Return success
|
// Return success
|
||||||
if(tag) {
|
if(tag && this.isLegalTag(tag.tag)) {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
// Look for the next match
|
// Look for the next match
|
||||||
@ -390,4 +390,17 @@ exports.findNextTag = function(source,pos,options) {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.isLegalTag = function(tag) {
|
||||||
|
// If it starts with a $ then we'll let anything go
|
||||||
|
if(tag.charAt(0) === "$") {
|
||||||
|
return true;
|
||||||
|
// If it starts with a dash then it's not legal
|
||||||
|
} else if(tag.charAt(0) === "-") {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// Otherwise it's OK
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user