@@ -1890,9 +1890,13 @@ get "/api/v1/comments/:id" do |env|
1890
1890
node_comment = node[" commentRenderer" ]
1891
1891
end
1892
1892
1893
- contentHtml = node_comment[" contentText" ][" simpleText" ]?.try & .as_s.rchop('\ufeff' )
1894
- contentHtml ||= node_comment[" contentText" ][" runs" ].as_a.map do |run |
1895
- text = run[" text" ].as_s
1893
+ content_html = node_comment[" contentText" ][" simpleText" ]?.try & .as_s.rchop('\ufeff' )
1894
+ if content_html
1895
+ content_html = HTML .escape(content_html)
1896
+ end
1897
+
1898
+ content_html ||= node_comment[" contentText" ][" runs" ].as_a.map do |run |
1899
+ text = HTML .escape(run[" text" ].as_s)
1896
1900
1897
1901
if run[" text" ] == " \n "
1898
1902
text = " <br>"
@@ -1924,7 +1928,7 @@ get "/api/v1/comments/:id" do |env|
1924
1928
text
1925
1929
end .join.rchop('\ufeff' )
1926
1930
1927
- contentHtml , content = html_to_content(contentHtml )
1931
+ content_html , content = html_to_content(content_html )
1928
1932
1929
1933
author = node_comment[" authorText" ]?.try & .[" simpleText" ]
1930
1934
author ||= " "
@@ -1953,7 +1957,7 @@ get "/api/v1/comments/:id" do |env|
1953
1957
published = decode_date(node_comment[" publishedTimeText" ][" runs" ][0 ][" text" ].as_s.rchop(" (edited)" ))
1954
1958
1955
1959
json.field " content" , content
1956
- json.field " contentHtml" , contentHtml
1960
+ json.field " contentHtml" , content_html
1957
1961
json.field " published" , published.epoch
1958
1962
json.field " likeCount" , node_comment[" likeCount" ]
1959
1963
json.field " commentId" , node_comment[" commentId" ]
0 commit comments