Commits

Kirill Simonov committed f23ca8c

Fix invalid output of single-quoted scalars in cases when a single
quote is not escaped when preceeded by whitespaces or line breaks.
(Fix #17).

  • Participants
  • Parent commits bab0035

Comments (0)

Files changed (3)

File lib/yaml/emitter.py

                             data = data.encode(self.encoding)
                         self.stream.write(data)
                         start = end
-                    if ch == u'\'':
-                        data = u'\'\''
-                        self.column += 2
-                        if self.encoding:
-                            data = data.encode(self.encoding)
-                        self.stream.write(data)
-                        start = end + 1
+            if ch == u'\'':
+                data = u'\'\''
+                self.column += 2
+                if self.encoding:
+                    data = data.encode(self.encoding)
+                self.stream.write(data)
+                start = end + 1
             if ch is not None:
                 spaces = (ch == u' ')
                 breaks = (ch in u'\n\x85\u2028\u2029')

File tests/data/invalid-single-quote-bug.code

+["foo 'bar'", "foo\n'bar'"]

File tests/data/invalid-single-quote-bug.data

+- "foo 'bar'"
+- "foo\n'bar'"