DiegoAstiazaran updated this revision to Diff 211201. DiegoAstiazaran marked an inline comment as done. DiegoAstiazaran edited the summary of this revision. DiegoAstiazaran added a comment.
Use printHTMLEscaped() in ADT/StringExtras.h to write HTML entities. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65107/new/ https://reviews.llvm.org/D65107 Files: clang-tools-extra/clang-doc/HTMLGenerator.cpp clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp @@ -258,6 +258,15 @@ 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 @@ <p> Extended description that continues onto the next line. </p> + <p> + Comment with html entities: &, <, >, ", '. + </p> </div> </div> </div> Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp =================================================================== --- clang-tools-extra/clang-doc/HTMLGenerator.cpp +++ 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 @@ 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) {
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp @@ -258,6 +258,15 @@ 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 @@ <p> Extended description that continues onto the next line. </p> + <p> + Comment with html entities: &, <, >, ", '. + </p> </div> </div> </div> Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp =================================================================== --- clang-tools-extra/clang-doc/HTMLGenerator.cpp +++ 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 @@ 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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits