summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-doc/HTMLGenerator.cpp3
-rw-r--r--clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp12
2 files changed, 14 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index e47119336ab..64e0677d404 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -8,6 +8,7 @@
#include "Generators.h"
#include "Representation.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@@ -176,7 +177,7 @@ llvm::SmallString<16> HTMLTag::ToString() const {
void TextNode::Render(llvm::raw_ostream &OS, int IndentationLevel) {
if (Indented)
OS.indent(IndentationLevel * 2);
- OS << Text;
+ printHTMLEscaped(Text, OS);
}
void TagNode::Render(llvm::raw_ostream &OS, int IndentationLevel) {
diff --git a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
index eabc6d45fe5..af3a661e6b6 100644
--- a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -258,6 +258,15 @@ TEST(HTMLGeneratorTest, emitCommentHTML) {
Extended->Children.back()->Kind = "TextComment";
Extended->Children.back()->Text = " continues onto the next line.";
+ Top.Children.emplace_back(llvm::make_unique<CommentInfo>());
+ CommentInfo *Entities = Top.Children.back().get();
+ Entities->Kind = "ParagraphComment";
+ Entities->Children.emplace_back(llvm::make_unique<CommentInfo>());
+ Entities->Children.back()->Kind = "TextComment";
+ Entities->Children.back()->Name = "ParagraphComment";
+ Entities->Children.back()->Text =
+ " Comment with html entities: &, <, >, \", \'.";
+
I.Description.emplace_back(std::move(Top));
auto G = getHTMLGenerator();
@@ -285,6 +294,9 @@ TEST(HTMLGeneratorTest, emitCommentHTML) {
<p>
Extended description that continues onto the next line.
</p>
+ <p>
+ Comment with html entities: &amp;, &lt;, &gt;, &quot;, &apos;.
+ </p>
</div>
</div>
</div>
OpenPOWER on IntegriCloud