Show More
@@ -623,7 +623,21 b' def parsestring(s, quoted=True):' | |||||
623 | if quoted: |
|
623 | if quoted: | |
624 | if len(s) < 2 or s[0] != s[-1]: |
|
624 | if len(s) < 2 or s[0] != s[-1]: | |
625 | raise SyntaxError(_('unmatched quotes')) |
|
625 | raise SyntaxError(_('unmatched quotes')) | |
626 | return s[1:-1] |
|
626 | # de-backslash-ify only <\">. it is invalid syntax in non-string part of | |
|
627 | # template, but we are likely to escape <"> in quoted string and it was | |||
|
628 | # accepted before, thanks to issue4290. <\\"> is unmodified because it | |||
|
629 | # is ambiguous and it was processed as such before 2.8.1. | |||
|
630 | # | |||
|
631 | # template result | |||
|
632 | # --------- ------------------------ | |||
|
633 | # {\"\"} parse error | |||
|
634 | # "{""}" {""} -> <> | |||
|
635 | # "{\"\"}" {""} -> <> | |||
|
636 | # {"\""} {"\""} -> <"> | |||
|
637 | # '{"\""}' {"\""} -> <"> | |||
|
638 | # "{"\""}" parse error (don't care) | |||
|
639 | q = s[0] | |||
|
640 | return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q) | |||
627 |
|
641 | |||
628 | return s |
|
642 | return s | |
629 |
|
643 |
@@ -2313,6 +2313,25 b' Test string escaping:' | |||||
2313 | <>\n<]> |
|
2313 | <>\n<]> | |
2314 | <>\n< |
|
2314 | <>\n< | |
2315 |
|
2315 | |||
|
2316 | Test exception in quoted template. single backslash before quotation mark is | |||
|
2317 | stripped before parsing: | |||
|
2318 | ||||
|
2319 | $ cat <<'EOF' > escquotetmpl | |||
|
2320 | > changeset = "\" \\" \\\" \\\\" {files % \"{file}\"}\n" | |||
|
2321 | > EOF | |||
|
2322 | $ cd latesttag | |||
|
2323 | $ hg log -r 2 --style ../escquotetmpl | |||
|
2324 | " \" \" \\" head1 | |||
|
2325 | ||||
|
2326 | $ hg log -r 2 -T esc --config templates.esc='{\"invalid\"}\n' | |||
|
2327 | hg: parse error at 1: syntax error | |||
|
2328 | [255] | |||
|
2329 | $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"' | |||
|
2330 | valid | |||
|
2331 | $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'" | |||
|
2332 | valid | |||
|
2333 | $ cd .. | |||
|
2334 | ||||
2316 | Test leading backslashes: |
|
2335 | Test leading backslashes: | |
2317 |
|
2336 | |||
2318 | $ cd latesttag |
|
2337 | $ cd latesttag |
General Comments 0
You need to be logged in to leave comments.
Login now