diff --git a/src/mako/cli/lib/argparse.mako b/src/mako/cli/lib/argparse.mako index b3c77b4521..e538bf61bc 100644 --- a/src/mako/cli/lib/argparse.mako +++ b/src/mako/cli/lib/argparse.mako @@ -2,7 +2,7 @@ <%! import os - from util import (put_and, supports_scopes, api_index, indent_by, enclose_in, put_and) + from util import (put_and, supports_scopes, api_index, indent_by, enclose_in, put_and, escape_rust_string) from cli import (mangle_subcommand, new_method_context, PARAM_FLAG, STRUCT_FLAG, UPLOAD_FLAG, OUTPUT_FLAG, VALUE_ARG, CONFIG_DIR, SCOPE_FLAG, is_request_value_property, FIELD_SEP, docopt_mode, FILE_ARG, MIME_ARG, OUT_ARG, CONFIG_DIR_FLAG, KEY_VALUE_ARG, to_docopt_arg, DEBUG_FLAG, DEBUG_AUTH_FLAG, MODE_ARG, SCOPE_ARG, @@ -239,7 +239,7 @@ let mut app = App::new("${util.program_name()}") .author("${', '.join(cargo.authors)}") .version("${util.crate_version()}") % if description is not UNDEFINED: -.about("${description}") +.about("${escape_rust_string(description)}") % endif .after_help("${url_info}") % for flag, desc, arg_name, multiple in global_args: diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 0e3b477507..1085e91c83 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -217,6 +217,10 @@ def markdown_comment(s): def estr(l): return ['"%s"' % i for i in l] +# escape all '"' with '\"' +def escape_rust_string(s): + return s.replace('"', '\\"') + ## -- End Filters -- @} # ==============================================================================