Permalink
Browse files

Modify example:

- Use bash $'' because it's not specific to git.  It can be used with
  other tools too.
- 0x01 and 0x02 so as not to confuse the issue of NUL in bash strings
  • Loading branch information...
Andy Chu
Andy Chu committed Sep 19, 2017
1 parent 7fa3cba commit a0896171b3f7c2c408b4228c034edabb8a0816c7
Showing with 5 additions and 5 deletions.
  1. +5 −5 git-changelog/demo.sh
View
@@ -10,7 +10,7 @@ escape-segments() {
import cgi, re, sys
print re.sub(
r"\x00(.*)\x01",
r"\x01(.*)\x02",
lambda match: cgi.escape(match.group(1)),
sys.stdin.read())
'
@@ -30,12 +30,12 @@ EOF
# - a trick for HTML escaping (avoid XSS): surround %s with unlikely bytes,
# \x00 and \x01. Then pipe Python to escape.
local format='
local format=$'
<tr>
<td><a href="https://github.com/oilshell/blog-code/commit/%H">%h</a> </td>
<td class="subject">%x00%s%x01</td>
<td> <a href="https://github.com/oilshell/blog-code/commit/%H">%h</a> </td>
<td>\x01%s\x02</td>
</tr>'
git log -n 3 --pretty="format:$format" | escape-segments
git log -n 5 --pretty="format:$format" | escape-segments
cat <<EOF
</table>

0 comments on commit a089617

Please sign in to comment.