Mercurial > hg
comparison tests/run-tests.py @ 25051:9c28f3236677
run-tests: do cdata escaping using bytes instead of str
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 14 Apr 2015 16:18:11 -0400 |
parents | 28526bb5b3b5 |
children | c4217a046b62 |
comparison
equal
deleted
inserted
replaced
25050:28526bb5b3b5 | 25051:9c28f3236677 |
---|---|
352 | 352 |
353 return log(*msg) | 353 return log(*msg) |
354 | 354 |
355 # Bytes that break XML even in a CDATA block: control characters 0-31 | 355 # Bytes that break XML even in a CDATA block: control characters 0-31 |
356 # sans \t, \n and \r | 356 # sans \t, \n and \r |
357 CDATA_EVIL = re.compile(r"[\000-\010\013\014\016-\037]") | 357 CDATA_EVIL = re.compile(br"[\000-\010\013\014\016-\037]") |
358 | 358 |
359 def cdatasafe(data): | 359 def cdatasafe(data): |
360 """Make a string safe to include in a CDATA block. | 360 """Make a string safe to include in a CDATA block. |
361 | 361 |
362 Certain control characters are illegal in a CDATA block, and | 362 Certain control characters are illegal in a CDATA block, and |
363 there's no way to include a ]]> in a CDATA either. This function | 363 there's no way to include a ]]> in a CDATA either. This function |
364 replaces illegal bytes with ? and adds a space between the ]] so | 364 replaces illegal bytes with ? and adds a space between the ]] so |
365 that it won't break the CDATA block. | 365 that it won't break the CDATA block. |
366 """ | 366 """ |
367 return CDATA_EVIL.sub('?', data).replace(']]>', '] ]>') | 367 return CDATA_EVIL.sub(b'?', data).replace(b']]>', b'] ]>') |
368 | 368 |
369 def log(*msg): | 369 def log(*msg): |
370 """Log something to stdout. | 370 """Log something to stdout. |
371 | 371 |
372 Arguments are strings to print. | 372 Arguments are strings to print. |