Skip to content

Commit

Permalink
Fix the parse bug for comment under the last argument (#12521)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoxing-ms authored Mar 30, 2020
1 parent 30012ef commit a792aaa
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 245 deletions.
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ def _urlretrieve(url):
def _remove_comments_from_json(template):
from jsmin import jsmin

# When commenting at the bottom of all elements in a JSON object, jsmin has a bug that will wrap lines.
# It will affect the subsequent multi-line processing logic, so deal with this situation in advance here.
template = re.sub(r'(^[\t ]*//[\s\S]*?\n)|(^[\t ]*/\*{1,2}[\s\S]*?\*/)', '', template, flags=re.M)
minified = jsmin(template)
# Get rid of multi-line strings. Note, we are not sending it on the wire rather just extract parameters to prompt for values
result = re.sub(r'"[^"]*?\n[^"]*?(?<!\\)"', '"#Azure Cli#"', minified, re.DOTALL)
Expand Down
Loading

0 comments on commit a792aaa

Please sign in to comment.