File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const PythonShell = require("python-shell");
4
4
const terminate = require ( "terminate" ) ;
5
5
const dialog = require ( "electron" ) . remote . require ( "electron" ) . dialog ;
6
6
const ipcRenderer = require ( "electron" ) . ipcRenderer ;
7
+ const jsesc = require ( 'jsesc' ) ;
7
8
8
9
var instapyPath = "" ;
9
10
var pyshell ;
@@ -242,7 +243,20 @@ var app = {
242
243
value = `'${ media . commentsMedia } '` ;
243
244
}
244
245
245
- content = `\nsession.set_do_comment(enabled=True, percentage=${ data . commentsPercent } )\nsession.set_comments([${ data . comments } ], media=${ value } )` ;
246
+ // Escape to handle non-ascii input.
247
+ var escapedComments = jsesc ( data . comments , {
248
+ 'quotes' : 'double'
249
+ } )
250
+
251
+ // Add `u`(Python unicode indentifier) beginning of each comment.
252
+ escapedComments =
253
+ 'u' +
254
+ escapedComments
255
+ . replace ( / \s + / g, "" )
256
+ . split ( "'," )
257
+ . join ( "', u" ) ;
258
+
259
+ content = `\nsession.set_do_comment(enabled=True, percentage=${ data . commentsPercent } )\nsession.set_comments([${ escapedComments } ], media=${ value } )` ;
246
260
}
247
261
248
262
return content ;
Original file line number Diff line number Diff line change 33
33
"fs-jetpack" : " ^1.2.0" ,
34
34
"jquery" : " ^3.2.1" ,
35
35
"python-shell" : " ^0.4.0" ,
36
- "terminate" : " ^2.1.0"
36
+ "terminate" : " ^2.1.0" ,
37
+ "jsesc" : " ^0.3.0"
37
38
},
38
39
"build" : {
39
40
"appId" : " com.ahmadudin.instapygui" ,
You can’t perform that action at this time.
0 commit comments