Skip to content

Commit

Permalink
fix(CLI): escape subcommand descriptions
Browse files Browse the repository at this point in the history
Otherwise, we could have had invalid rust strings.

[skip ci]
  • Loading branch information
Byron committed Apr 30, 2015
1 parent bd27046 commit fac5041
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mako/cli/lib/argparse.mako
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
if isinstance(v, bool):
v = v and 'true' or 'false'
elif isinstance(v, basestring):
v = '"%s"' % v
v = '"%s"' % v.replace('"', r'\"')
elif isinstance(v, list):
v = 'vec![%s]' % ','.join('UploadProtocol::%s' % p.capitalize() for p in v)
return 'Some(%s)' % v
Expand Down

2 comments on commit fac5041

@killercup
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use raw string literals (r#"Some "fancy" description"#) instead.

@Byron
Copy link
Owner Author

@Byron Byron commented on fac5041 May 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, good point ! I wasn't aware of their existence at all.
Also I believe it's the better solution, as it should protect other, unusual cases by default.
Will be improved via #100.

Please sign in to comment.