1.1 --- a/MoinSupport.py Fri Oct 11 08:29:45 2013 +0200
1.2 +++ b/MoinSupport.py Sat Oct 12 19:10:22 2013 +0200
1.3 @@ -509,6 +509,35 @@
1.4
1.5 return parameters
1.6
1.7 +# Macro argument quoting.
1.8 +
1.9 +def quoteMacroArguments(args):
1.10 +
1.11 + """
1.12 + Quote the given 'args' - a collection of (name, value) tuples - returning a
1.13 + string containing the comma-separated, quoted arguments.
1.14 + """
1.15 +
1.16 + quoted = []
1.17 +
1.18 + for name, value in args:
1.19 + quoted.append(quoteMacroArgument(name, value))
1.20 +
1.21 + return ",".join(quoted)
1.22 +
1.23 +def quoteMacroArgument(name, value):
1.24 +
1.25 + """
1.26 + Quote the argument with the given 'name' (or None indicating an unnamed
1.27 + argument) and 'value' so that it can be used with a macro.
1.28 + """
1.29 +
1.30 + value = unicode(value).replace('"', '""')
1.31 + if name is None:
1.32 + return '"%s"' % value
1.33 + else:
1.34 + return '"%s=%s"' % (name, value)
1.35 +
1.36 # Request-related classes and associated functions.
1.37
1.38 class Form: