Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] Docparse: Escape | in table content
@ 2020-12-16 14:32 Petr Vorel
  2020-12-16 14:42 ` Cyril Hrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2020-12-16 14:32 UTC (permalink / raw)
  To: ltp

31708e815 added | in values displayed in table, which unescaped breaks
table formatting.

NOTE: Due asciidoc{,tor} markup design it's difficult to easily escape markup
handling only this particular case.

https://github.com/asciidoctor/asciidoctor/issues/901
https://discuss.asciidoctor.org/Difficulty-in-consistently-escaping-markup-td5318.html

Fixes: #754

Reported-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 docparse/testinfo.pl | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/docparse/testinfo.pl b/docparse/testinfo.pl
index d8d9ea663..5aa7315e4 100755
--- a/docparse/testinfo.pl
+++ b/docparse/testinfo.pl
@@ -119,6 +119,14 @@ sub table
 	return "|===\n";
 }
 
+sub table_escape
+{
+	my $out = $_[0];
+
+	$out =~ s/\|/\\|/g;
+	return $out;
+}
+
 sub print_defined
 {
 	my ($key, $val, $val2) = @_;
@@ -329,10 +337,11 @@ sub content_all_tests
 
 			$content .= "|" . tag2title($k) . "\n|";
 			if (ref($v) eq 'ARRAY') {
-				$content .= join(', ', @$v),
+				$content .= table_escape(join(', ', @$v));
 			} else {
-				$content .= $v;
+				$content .= table_escape($v);
 			}
+
 			$content .= "\n";
 
 			$tmp2 = 1;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-16 21:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-16 14:32 [LTP] [PATCH 1/1] Docparse: Escape | in table content Petr Vorel
2020-12-16 14:42 ` Cyril Hrubis
2020-12-16 15:10   ` Petr Vorel
2020-12-16 15:30     ` Cyril Hrubis
2020-12-16 16:02       ` Petr Vorel
2020-12-16 19:15         ` Petr Vorel
2020-12-16 21:14       ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox