From: Juliana Rodrigueiro
Date: Wed, 26 Jul 2017 21:52:34 +0000 (+0200)
Subject: Cosmetic changes and typos correction
X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=a7e4c2f3c0dd215d94c1d8e91565d4437ca37158;p=libi2ncommon
Cosmetic changes and typos correction
---
diff --git a/src/restricted_html.cpp b/src/restricted_html.cpp
index 6796d1e..428edca 100644
--- a/src/restricted_html.cpp
+++ b/src/restricted_html.cpp
@@ -115,7 +115,7 @@ bool link_sanitizer(string &tag)
}
/**
- * @brief Check if tag is in a whitelist of alowed tags.
+ * @brief Check if tag is in a whitelist of allowed tags.
* Does not accept a tag containing attributes.
* Example:
* or
returns true.
@@ -149,7 +149,7 @@ const string restrict_html(const string &html_code_orig, bool strip)
string result = "";
vector expected_tags;
- BOOST_FOREACH(TOKEN s, tokenized)
+ BOOST_FOREACH(const TOKEN &s, tokenized)
{
if (!s.second)
{
@@ -162,7 +162,7 @@ const string restrict_html(const string &html_code_orig, bool strip)
{
result = result + s.first;
if (to_lower(s.first).compare("
") != 0)
- expected_tags.push_back(s.first.insert(1,"/"));
+ expected_tags.push_back(""+s.first.substr(1));
continue;
}
else if (expected_tags.size() > 0 && expected_tags.back().compare(s.first) == 0)
@@ -173,9 +173,10 @@ const string restrict_html(const string &html_code_orig, bool strip)
}
}
- if (to_lower(s.first).compare(0, AHREF.size(), AHREF) == 0 && link_sanitizer(s.first))
+ string tag = s.first;
+ if (to_lower(s.first).compare(0, AHREF.size(), AHREF) == 0 && link_sanitizer(tag))
{
- result = result + s.first;
+ result = result + tag;
expected_tags.push_back("");
continue;
}
@@ -185,10 +186,12 @@ const string restrict_html(const string &html_code_orig, bool strip)
}
if (expected_tags.size() > 0) //One or more tags were not closed.
+ {
BOOST_REVERSE_FOREACH(const string &s, expected_tags)
{
result = result + s;
}
+ }
return result.c_str();
}
diff --git a/src/restricted_html.hpp b/src/restricted_html.hpp
index ed5711e..00140ac 100644
--- a/src/restricted_html.hpp
+++ b/src/restricted_html.hpp
@@ -54,7 +54,7 @@ namespace I2n
/**
* @brief Restricts html code to a small list of allowed tags.
* The attribute "href" from the tag "a" has its value sanitized and if it
- * contains unsafe caracters, the tag is stripped.
+ * contains unsafe characters, the tag is stripped.
* The link sanitizer adds a redirector in case of an acceptable protocol, strip otherwise.
* Any other attributes found will result in the tag being stripped.
* Any comments will be excluded.