Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 10d096f

Browse files
committedMar 22, 2015
Escape double quotes, not single
1 parent 9f89117 commit 10d096f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎prometheus_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def generate_latest(registry=REGISTRY):
418418
if labels:
419419
labelstr = '{{{0}}}'.format(','.join(
420420
['{0}="{1}"'.format(
421-
k, v.replace('\\', r'\\').replace('\n', r'\n').replace('\'', r'\''))
421+
k, v.replace('\\', r'\\').replace('\n', r'\n').replace('"', r'\"'))
422422
for k, v in labels.items()]))
423423
else:
424424
labelstr = ''

‎tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ def test_unicode(self):
262262

263263
def test_escaping(self):
264264
c = Counter('cc', 'A\ncount\\er', ['a'], registry=self.registry)
265-
c.labels('\\x\n').inc(1)
266-
self.assertEqual(b'# HELP cc A\\ncount\\\\er\n# TYPE cc counter\ncc{a="\\\\x\\n"} 1.0\n', generate_latest(self.registry))
265+
c.labels('\\x\n"').inc(1)
266+
self.assertEqual(b'# HELP cc A\\ncount\\\\er\n# TYPE cc counter\ncc{a="\\\\x\\n\\""} 1.0\n', generate_latest(self.registry))
267267

268268

269269
if __name__ == '__main__':

0 commit comments

Comments
 (0)
Failed to load comments.