mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +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
|
||||
var tag = this.parseTag(source,match.index,options);
|
||||
// Return success
|
||||
if(tag) {
|
||||
if(tag && this.isLegalTag(tag.tag)) {
|
||||
return tag;
|
||||
}
|
||||
// Look for the next match
|
||||
@ -390,4 +390,17 @@ exports.findNextTag = function(source,pos,options) {
|
||||
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…
Reference in New Issue
Block a user