You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2022/07/09 08:56:01 UTC

[lucene-jira-archive] branch escape-html created (now 106136d8)

This is an automated email from the ASF dual-hosted git repository.

tomoko pushed a change to branch escape-html
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git


      at 106136d8 escape HTML

This branch includes the following new commits:

     new 106136d8 escape HTML

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene-jira-archive] 01/01: escape HTML

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomoko pushed a commit to branch escape-html
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git

commit 106136d82bd25e29677c81a10c0fbe4beb0e225b
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sat Jul 9 17:55:50 2022 +0900

    escape HTML
---
 migration/src/jira_util.py           |  3 ++-
 migration/src/markup/text_effects.py | 12 +++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/migration/src/jira_util.py b/migration/src/jira_util.py
index ac262786..32378994 100644
--- a/migration/src/jira_util.py
+++ b/migration/src/jira_util.py
@@ -10,7 +10,7 @@ from jira2markdown.markup.text_effects import BlockQuote, Quote, Monospaced
 from jira2markdown.markup.text_breaks import Ruler
 
 from markup.lists import UnorderedTweakedList, OrderedTweakedList
-from markup.text_effects import TweakedBlockQuote, TweakedQuote, TweakedMonospaced
+from markup.text_effects import EscapeHtml, TweakedBlockQuote, TweakedQuote, TweakedMonospaced
 from markup.text_breaks import LongRuler
 
 
@@ -212,6 +212,7 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}) -> str:
     elements.replace(Quote, TweakedQuote)
     elements.replace(Monospaced, TweakedMonospaced)
     elements.insert_after(Ruler, LongRuler)
+    elements.append(EscapeHtml)
     text = jira2markdown.convert(text, elements=elements)
 
     # markup @ mentions with ``
diff --git a/migration/src/markup/text_effects.py b/migration/src/markup/text_effects.py
index f180370f..3a4e87aa 100644
--- a/migration/src/markup/text_effects.py
+++ b/migration/src/markup/text_effects.py
@@ -9,8 +9,8 @@ from pyparsing import (
     Literal,
     LineEnd,
     Combine,
+    Literal,
     replaceWith,
-
 )
 
 from jira2markdown.markup.base import AbstractMarkup
@@ -57,3 +57,13 @@ class TweakedMonospaced(AbstractMarkup):
     @property
     def expr(self) -> ParserElement:
         return QuotedString("{{", endQuoteChar="}}").setParseAction(self.action)
+
+
+class EscapeHtml(AbstractMarkup):
+    """
+    Escapes HTML characters that are not a part of any expression grammar
+    """
+
+    @property
+    def expr(self) -> ParserElement:
+        return Literal("<").setParseAction(replaceWith("&lt;")) ^ Literal(">").setParseAction(replaceWith("&gt;")) ^ Literal("&").setParseAction(replaceWith("&amp;"))