@@ -8,7 +8,7 @@ json-dotenv
8
8
9
9
from __future__ import absolute_import
10
10
11
- __version__ = '0.0.26 '
11
+ __version__ = '0.0.27 '
12
12
13
13
import argparse
14
14
import json
@@ -259,6 +259,10 @@ class JsonDotEnv(object): # pylint: disable=bad-option-value,useless-object-inhe
259
259
260
260
return "\n " .join (r )
261
261
262
+ @staticmethod
263
+ def _rstrip_cr (s ):
264
+ return re .sub (r'\\n$' , '' , s )
265
+
262
266
def _parse_file (self ):
263
267
if self .options .file == '-' :
264
268
xfile = StringIO (sys .stdin .read ())
@@ -277,27 +281,24 @@ class JsonDotEnv(object): # pylint: disable=bad-option-value,useless-object-inhe
277
281
if MATCH_VAR_NAME_QUOTE (x ):
278
282
if cur :
279
283
if quoted is False :
280
- cur = cur .rstrip ("\\ n" )
281
- cur += '"'
282
- content .append (self .escape_variable (cur .rstrip ("\\ n" )))
284
+ cur = self ._rstrip_cr (cur ) + '"'
285
+ content .append (self .escape_variable (self ._rstrip_cr (cur )))
283
286
quoted = True
284
287
cur = self .raw_string (x )
285
288
elif MATCH_VAR_NAME (x ):
286
289
if cur :
287
290
if quoted is False :
288
- cur = cur .rstrip ("\\ n" )
289
- cur += '"'
290
- content .append (self .escape_variable (cur .rstrip ("\\ n" )))
291
+ cur = self ._rstrip_cr (cur ) + '"'
292
+ content .append (self .escape_variable (self ._rstrip_cr (cur )))
291
293
quoted = False
292
294
cur = '{0}="{1}' .format (* self .raw_string (x ).split ('=' , 1 ))
293
295
else :
294
296
cur += self .raw_string (x )
295
297
296
298
if cur :
297
299
if quoted is False :
298
- cur = cur .rstrip ("\\ n" )
299
- cur += '"'
300
- content .append (self .escape_variable (cur .rstrip ("\\ n" )))
300
+ cur = self ._rstrip_cr (cur ) + '"'
301
+ content .append (self .escape_variable (self ._rstrip_cr (cur )))
301
302
302
303
if xfile :
303
304
xfile .close ()
0 commit comments