mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-11-02 21:14:27 +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:
1 parent
a9f2a24ace
commit
d5f09a4608
1 file changed
+14
-1
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
Reference in new issue
Block a user