Skip to contentSkip to conversation

Parametrize asciidoc and add --unsafe

PATCH In review Pavel Roskin 2 participants 3 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Parametrize asciidoc and add --unsafe

Including files from the parent directory is considered unsafe by asciidoc 7.1.0. This is used in git.txt, which includes ../README.

Since git is developed openly, we shouldn't be afraid of exploits lurking in the docs. Create a make variable ASCIIDOC and use it to always call asciidoc with the --unsafe option.

---

 Documentation/Makefile |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
Documentation/Makefile +7 -5
index a65fb1b..391f583 100644
@@ -28,6 +28,8 @@ man7=$(mandir)/man7
 
 INSTALL?=install
 
+ASCIIDOC = asciidoc --unsafe
+
 #
 # Please note that there is a minor bug in asciidoc.
 # The version after 6.0.3 _will_ include the patch found here:
@@ -69,20 +71,20 @@ clean:
 	rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep
 
 %.html : %.txt
-	asciidoc -b xhtml11 -d manpage -f asciidoc.conf $<
+	$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf $<
 
 %.1 %.7 : %.xml
 	xmlto man $<
 
 %.xml : %.txt
-	asciidoc -b docbook -d manpage -f asciidoc.conf $<
+	$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf $<
 
 git.html: git.txt ../README
 
 glossary.html : glossary.txt sort_glossary.pl
 	cat $< | \
 	perl sort_glossary.pl | \
-	asciidoc -b xhtml11 - > glossary.html
+	$(ASCIIDOC) -b xhtml11 - > glossary.html
 
 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
 	rm -f $@+ $@
@@ -90,13 +92,13 @@ howto-index.txt: howto-index.sh $(wildca
 	mv $@+ $@
 
 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
-	asciidoc -b xhtml11 $*.txt
+	$(ASCIIDOC) -b xhtml11 $*.txt
 
 WEBDOC_DEST = /pub/software/scm/git/docs
 
 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
 	rm -f $@+ $@
-	sed -e '1,/^$$/d' $? | asciidoc -b xhtml11 - >$@+
+	sed -e '1,/^$$/d' $? | $(ASCIIDOC) -b xhtml11 - >$@+
 	mv $@+ $@
 
 install-webdoc : html
Signature · 2 lines
Regards,
Pavel Roskin
#1 lore raw
Quoted 2 lines · Pavel Roskin

Including files from the parent directory is considered unsafe by asciidoc 7.1.0. This is used in git.txt, which includes ../README.

Is copying/linking README down when we build documentation a more conservative option, I wonder?

Does asciidoc prior to 7.1.0 do sensible thing given an --unsafe option? If not, how does one override ASCIIDOC from the command line to the toplevel "make"?

#2 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 2 lines · Pavel Roskin

Including files from the parent directory is considered unsafe by asciidoc 7.1.0. This is used in git.txt, which includes ../README.

Is copying/linking README down when we build documentation a more conservative option, I wonder?

I considered this possibility. I don't have a strong preference. The argument in favor of "--unsafe" is that adding a make target is more intrusive that adding a switch. Besides, we may want to include more files from other directories.

Quoted 3 lines

Does asciidoc prior to 7.1.0 do sensible thing given an --unsafe option? If not, how does one override ASCIIDOC from the command line to the toplevel "make"?

Good question. I misunderstood the asciidoc changelog. Older versions (before 7.0.4) understand "--safe", but not "--unsafe". Since version 7.0.4 is less than 2 months old, it would be reasonable not to go ahead with my patch right now.

Let's make a copy for now. Symbolic linking doesn't work - asciidoc recognizes and rejects symlinks.

---
[PATCH] Don't include ../README in git.txt - make a local copy

asciidoc 7.0.4 and newer considers such includes from parent directory unsafe.

---

 Documentation/.gitignore |    1 +
 Documentation/Makefile   |    9 ++++++---
 Documentation/git.txt    |    2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)
Documentation/.gitignore +1 -0
index 9fef490..c87c61a 100644
@@ -4,3 +4,4 @@
 *.7
 howto-index.txt
 doc.dep
+README
Documentation/Makefile +6 -3
index a65fb1b..a3bca86 100644
@@ -62,11 +62,14 @@ doc.dep : $(wildcard *.txt) build-docdep
 
 -include doc.dep
 
-git.7: ../README
+git.7: README
+
+README: ../README
+	cp $< $@
 
 
 clean:
-	rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep
+	rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep README
 
 %.html : %.txt
 	asciidoc -b xhtml11 -d manpage -f asciidoc.conf $<
@@ -77,7 +80,7 @@ clean:
 %.xml : %.txt
 	asciidoc -b docbook -d manpage -f asciidoc.conf $<
 
-git.html: git.txt ../README
+git.html: git.txt README
 
 glossary.html : glossary.txt sort_glossary.pl
 	cat $< | \
Documentation/git.txt +1 -1
index 25bcb84..e8ef3ef 100644
@@ -586,7 +586,7 @@ git Diffs
 
 Discussion[[Discussion]]
 ------------------------
-include::../README[]
+include::README[]
 
 Authors
 -------
Signature · 2 lines
Regards,
Pavel Roskin