Prevent HTML from being rendered in entries.

This commit is contained in:
Robbie Antenesse 2016-07-06 15:17:50 -06:00
parent 5d0d14cf24
commit 585eb29193
2 changed files with 16 additions and 16 deletions

View File

@ -95,7 +95,7 @@ function ShowWordEditForm(index) {
var indexString = index.toString(); // Variable for reduced processing
var word = currentDictionary.words[index]; // Reference for easier reading
var editForm = '<form id="editForm' + indexString + '">\
<h2>Editing ' + htmlEntitiesParse(word.name) + '</h2>\
<h2>Editing ' + word.name + '</h2>\
<label><span>Word</span>\
<input type="text" id="word' + indexString + '" value="' + htmlEntitiesParse(word.name) + '" onkeydown="SubmitWordOnCtrlEnter(this)" />\
</label>\
@ -228,13 +228,13 @@ function ShowDictionary() {
}
var dictionaryNameArea = document.getElementById("dictionaryName");
dictionaryNameArea.innerHTML = htmlEntitiesParse(currentDictionary.name) + " Dictionary";
dictionaryNameArea.innerHTML = currentDictionary.name + " Dictionary";
if (loggedIn && currentDictionary.settings.isPublic) {
dictionaryNameArea.innerHTML += "<a href='/" + currentDictionary.externalID + "' target='_blank' id='dictionaryShareLink' class='clickable' title='Share Dictionary'>&#10150;</a>";
}
var dictionaryDescriptionArea = document.getElementById("dictionaryDescription");
dictionaryDescriptionArea.innerHTML = marked(htmlEntitiesParse(currentDictionary.description));
dictionaryDescriptionArea.innerHTML = marked(currentDictionary.description);
var dictionaryArea = document.getElementById("theDictionary");
var dictionaryText = "";
@ -277,14 +277,14 @@ function DictionaryEntry(itemIndex) {
if (searchTerm != "" && searchByWord) {
// Parse HTML Entities while searching so the regex can search actual characters instead of HTML.
wordName += htmlEntitiesParse(currentDictionary.words[itemIndex].name).replace(searchRegEx, "<searchTerm>$1</searchterm>");
wordName += htmlEntities(htmlEntitiesParse(currentDictionary.words[itemIndex].name).replace(searchRegEx, "<searchTerm>$1</searchterm>"));
} else {
// Don't need to parse if not searching because HTML displays correctly anyway!
wordName += currentDictionary.words[itemIndex].name.toString(); // Use toString() to prevent using a reference instead of the value.
}
if (currentDictionary.words[itemIndex].pronunciation != "") {
wordPronunciation += marked(htmlEntitiesParse(currentDictionary.words[itemIndex].pronunciation)).replace("<p>","").replace("</p>","");
wordPronunciation += marked(currentDictionary.words[itemIndex].pronunciation).replace("<p>","").replace("</p>","");
}
if (currentDictionary.words[itemIndex].partOfSpeech != " " && currentDictionary.words[itemIndex].partOfSpeech != "") {
@ -293,7 +293,7 @@ function DictionaryEntry(itemIndex) {
if (currentDictionary.words[itemIndex].simpleDefinition != "") {
if (searchTerm != "" && searchBySimple) {
wordSimpleDefinition += htmlEntitiesParse(currentDictionary.words[itemIndex].simpleDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>");
wordSimpleDefinition += htmlEntities(htmlEntitiesParse(currentDictionary.words[itemIndex].simpleDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>"));
} else {
wordSimpleDefinition += currentDictionary.words[itemIndex].simpleDefinition.toString();
}
@ -301,9 +301,9 @@ function DictionaryEntry(itemIndex) {
if (currentDictionary.words[itemIndex].longDefinition != "") {
if (searchTerm != "" && searchByLong) {
wordLongDefinition += marked(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>"));
wordLongDefinition += marked(htmlEntities(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>")));
} else {
wordLongDefinition += marked(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition));
wordLongDefinition += marked(currentDictionary.words[itemIndex].longDefinition);
}
}

View File

@ -40,10 +40,10 @@ function ShowPublicDictionary(ignoreFilters) {
}
var dictionaryNameArea = document.getElementById("dictionaryName");
dictionaryNameArea.innerHTML = htmlEntitiesParse(publicDictionary.name) + " Dictionary";
dictionaryNameArea.innerHTML = publicDictionary.name + " Dictionary";
var dictionaryByArea = document.getElementById("dictionaryBy");
dictionaryByArea.innerHTML = "created by " + htmlEntitiesParse(publicDictionary.createdBy);
dictionaryByArea.innerHTML = "created by " + publicDictionary.createdBy;
var dictionaryIncompleteArea = document.getElementById("incompleteNotice");
if (!publicDictionary.settings.isComplete) {
@ -51,7 +51,7 @@ function ShowPublicDictionary(ignoreFilters) {
}
var dictionaryDescriptionArea = document.getElementById("dictionaryDescription");
dictionaryDescriptionArea.innerHTML = marked(htmlEntitiesParse(publicDictionary.description));
dictionaryDescriptionArea.innerHTML = marked(publicDictionary.description);
var dictionaryArea = document.getElementById("theDictionary");
var dictionaryText = "";
@ -97,13 +97,13 @@ function PublicDictionaryEntry(itemIndex, ignoreFilters) {
var wordName = wordPronunciation = wordPartOfSpeech = wordSimpleDefinition = wordLongDefinition = "";
if (searchTerm != "" && searchByWord) {
wordName += htmlEntitiesParse(publicDictionary.words[itemIndex].name).replace(searchRegEx, "<searchTerm>$1</searchterm>");
wordName += htmlEntities(htmlEntitiesParse(publicDictionary.words[itemIndex].name).replace(searchRegEx, "<searchTerm>$1</searchterm>"));
} else {
wordName += publicDictionary.words[itemIndex].name.toString(); // Use toString() to prevent using a reference instead of the value.
}
if (publicDictionary.words[itemIndex].pronunciation != "") {
wordPronunciation += marked(htmlEntitiesParse(publicDictionary.words[itemIndex].pronunciation)).replace("<p>","").replace("</p>","");
wordPronunciation += marked(publicDictionary.words[itemIndex].pronunciation).replace("<p>","").replace("</p>","");
}
if (publicDictionary.words[itemIndex].partOfSpeech != "") {
@ -112,7 +112,7 @@ function PublicDictionaryEntry(itemIndex, ignoreFilters) {
if (publicDictionary.words[itemIndex].simpleDefinition != "") {
if (searchTerm != "" && searchBySimple) {
wordSimpleDefinition += htmlEntitiesParse(publicDictionary.words[itemIndex].simpleDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>");
wordSimpleDefinition += htmlEntities(htmlEntitiesParse(publicDictionary.words[itemIndex].simpleDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>"));
} else {
wordSimpleDefinition += publicDictionary.words[itemIndex].simpleDefinition.toString();
}
@ -120,9 +120,9 @@ function PublicDictionaryEntry(itemIndex, ignoreFilters) {
if (publicDictionary.words[itemIndex].longDefinition != "") {
if (searchTerm != "" && searchByLong) {
wordLongDefinition += marked(htmlEntitiesParse(publicDictionary.words[itemIndex].longDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>"));
wordLongDefinition += marked(htmlEntities(htmlEntitiesParse(publicDictionary.words[itemIndex].longDefinition).replace(searchRegEx, "<searchTerm>$1</searchterm>")));
} else {
wordLongDefinition += marked(htmlEntitiesParse(publicDictionary.words[itemIndex].longDefinition));
wordLongDefinition += marked(publicDictionary.words[itemIndex].longDefinition);
}
}