Escape strings with string_escape rather than tojson
This commit is contained in:
parent
5bc794f85a
commit
7f5a79cdfd
@ -30,7 +30,8 @@ import textwrap
|
|||||||
import attr
|
import attr
|
||||||
from PyQt5.QtCore import pyqtSignal, QObject, QUrl
|
from PyQt5.QtCore import pyqtSignal, QObject, QUrl
|
||||||
|
|
||||||
from qutebrowser.utils import log, standarddir, jinja, objreg, utils
|
from qutebrowser.utils import (log, standarddir, jinja, objreg, utils,
|
||||||
|
javascript)
|
||||||
from qutebrowser.commands import cmdutils
|
from qutebrowser.commands import cmdutils
|
||||||
from qutebrowser.browser import downloads
|
from qutebrowser.browser import downloads
|
||||||
|
|
||||||
@ -106,9 +107,10 @@ class GreasemonkeyScript:
|
|||||||
"""
|
"""
|
||||||
template = jinja.js_environment.get_template('greasemonkey_wrapper.js')
|
template = jinja.js_environment.get_template('greasemonkey_wrapper.js')
|
||||||
return template.render(
|
return template.render(
|
||||||
scriptName="/".join([self.namespace or '', self.name]),
|
scriptName=javascript.string_escape(
|
||||||
|
"/".join([self.namespace or '', self.name])),
|
||||||
scriptInfo=self._meta_json(),
|
scriptInfo=self._meta_json(),
|
||||||
scriptMeta=self.script_meta,
|
scriptMeta=javascript.string_escape(self.script_meta),
|
||||||
scriptSource=self._code)
|
scriptSource=self._code)
|
||||||
|
|
||||||
def _meta_json(self):
|
def _meta_json(self):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
const _qute_script_id = "__gm_" + {{ scriptName | tojson }};
|
const _qute_script_id = "__gm_" + "{{ scriptName }}";
|
||||||
|
|
||||||
function GM_log(text) {
|
function GM_log(text) {
|
||||||
console.log(text);
|
console.log(text);
|
||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
const GM_info = {
|
const GM_info = {
|
||||||
'script': {{ scriptInfo }},
|
'script': {{ scriptInfo }},
|
||||||
'scriptMetaStr': {{ scriptMeta | tojson }},
|
'scriptMetaStr': "{{ scriptMeta }}",
|
||||||
'scriptWillUpdate': false,
|
'scriptWillUpdate': false,
|
||||||
'version': "0.0.1",
|
'version': "0.0.1",
|
||||||
// so scripts don't expect exportFunction
|
// so scripts don't expect exportFunction
|
||||||
|
Loading…
Reference in New Issue
Block a user