本文整理汇总了Python中dNG.data.text.input_filter.InputFilter.filter_control_chars方法的典型用法代码示例。如果您正苦于以下问题:Python InputFilter.filter_control_chars方法的具体用法?Python InputFilter.filter_control_chars怎么用?Python InputFilter.filter_control_chars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dNG.data.text.input_filter.InputFilter
的用法示例。
在下文中一共展示了InputFilter.filter_control_chars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_dsd
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def parse_dsd(dsd):
"""
DSD stands for dynamic service data and should be used for transfering IDs for
news, topics, ... Take care for injection attacks!
:param dsd: DSD string for parsing
:return: (dict) Parsed DSD
:since: v1.0.0
"""
dsd = InputFilter.filter_control_chars(dsd)
if ("+" not in dsd and VirtualRoute.RE_PLUS_ENCODED_CHAR.search(dsd) is not None): dsd = Uri.decode_query_value(dsd)
elif (" " in dsd): dsd = Uri.encode_query_value(dsd)
dsd = VirtualRoute.RE_DSD_PLUS_SPAM_CHAR.sub("++", dsd)
dsd_list = dsd.split("++")
_return = { }
for dsd in dsd_list:
dsd_element = dsd.strip().split("+", 1)
if (len(dsd_element) > 1):
_return[dsd_element[0]] = InputFilter.filter_control_chars(Uri.decode_query_value(dsd_element[1]))
elif (len(dsd_element[0]) > 0): _return[dsd_element[0]] = ""
#
return _return
示例2: execute_new
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute_new(self, is_save_mode = False):
#
"""
Action for "new"
:since: v0.1.00
"""
# pylint: disable=star-args
tid = InputFilter.filter_file_path(self.request.get_dsd("dtid", ""))
oid = InputFilter.filter_file_path(self.request.get_dsd("doid", ""))
source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()
if (source_iline == ""):
#
source_iline = ("m=discuss;dsd=dpid+{0}".format(Link.encode_query_value(oid))
if (tid == "") else
"m=discuss;dsd=dtid+{0}".format(Link.encode_query_value(tid))
)
#
if (target_iline == ""): target_iline = "m=discuss;dsd=dpid+__id_d__"
if (tid != ""): oid = tid
self._execute_new("new",
oid,
source_iline = source_iline,
target_iline = target_iline,
is_save_mode = is_save_mode
)
示例3: execute_new
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute_new(self, is_save_mode = False):
#
"""
Action for "new"
:since: v0.1.00
"""
form_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_id", "")).strip()
form_field_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_field_id", "")).strip()
L10n.init("pas_http_core_form")
form = FormProcessor(form_id)
form.set_form_render_id(Binary.str(hexlify(urandom(16))))
if (is_save_mode): form.set_input_available()
self._apply_new_form(form)
if (is_save_mode and form.check()):
#
entry_data = self._save_new_form(form)
form_store = form.get_form_store()
form_store_dict = form_store.get_value_dict()
form_store_field_id = "form_api_dynamic_{0}".format(form_field_id)
entry_list = form_store_dict.get(form_store_field_id, [ ])
entry_list.append(entry_data)
form_store_dict[form_store_field_id] = entry_list
form_store.set_value_dict(form_store_dict)
self._set_destroy_dom_result()
#
else:
#
content = { "title": self._get_form_action_new_title(),
"on_closed_query": Link().build_url(Link.TYPE_QUERY_STRING, { "__request__": True, "a": "get" })
}
content['form'] = { "object": form,
"url_parameters": { "__request__": True,
"a": "new-save"
},
"button_title": "core_continue"
}
method = (self._set_replace_dom_oset_result
if (is_save_mode) else
self._set_append_overlay_dom_oset_result
)
method("dynamic_form.overlay", content)
示例4: execute_delete
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute_delete(self):
"""
Action for "delete"
:since: v0.2.00
"""
cid = InputFilter.filter_file_path(self.request.get_dsd("mcid", ""))
source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()
if (source_iline == ""): source_iline = "m=mp;a=list_root_containers"
if (target_iline == ""): target_iline = source_iline
L10n.init("mp_core")
session = (self.request.get_session() if (self.request.is_supported("session")) else None)
user_profile = (None if (session is None) else session.get_user_profile())
if (user_profile is None
or (not user_profile.is_type("ad"))
): raise TranslatableError("core_access_denied", 403)
try: mp_entry = MpEntry.load_id(cid)
except NothingMatchedException as handled_exception: raise TranslatableError("mp_core_cid_invalid", 404, _exception = handled_exception)
if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")
Link.set_store("servicemenu",
Link.TYPE_RELATIVE_URL,
L10n.get("core_back"),
{ "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
icon = "mini-default-back",
priority = 7
)
if (not DatabaseTasks.is_available()): raise TranslatableException("pas_core_tasks_daemon_not_available")
mp_entry.delete()
database_tasks = DatabaseTasks.get_instance()
database_tasks.add("dNG.pas.upnp.Resource.onDeleted.{0}".format(cid), "dNG.pas.upnp.Resource.onDeleted", 1, container_id = cid)
database_tasks.add("dNG.pas.upnp.Resource.onRootContainerDeleted.{0}".format(cid), "dNG.pas.upnp.Resource.onRootContainerDeleted", 1, container_id = cid)
target_iline = re.sub("\\_\\w+\\_\\_", "", target_iline)
NotificationStore.get_instance().add_completed_info(L10n.get("mp_core_done_root_container_delete"))
Link.clear_store("servicemenu")
redirect_request = PredefinedHttpRequest()
redirect_request.set_iline(target_iline)
self.request.redirect(redirect_request)
示例5: execute_logout
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute_logout(self):
"""
Action for "logout"
:since: v0.2.00
"""
source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()
if (target_iline == ""):
if (Settings.is_defined("pas_http_user_logout_default_target_lang_{0}".format(self.request.get_lang()))): target_iline = Settings.get("pas_http_user_logout_default_target_lang_{0}".format(self.request.get_lang()))
elif (Settings.is_defined("pas_http_user_logout_default_target")): target_iline = Settings.get("pas_http_user_logout_default_target")
else: target_iline = source_iline
#
L10n.init("pas_http_user")
if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")
Link.set_store("servicemenu",
Link.TYPE_RELATIVE_URL,
L10n.get("core_back"),
{ "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
icon = "mini-default-back",
priority = 7
)
if (not self.request.is_supported("session")): raise TranslatableError("core_unknown_error", 500)
session = Session.load(session_create = False)
if (session is not None):
session.delete()
self.request.set_session(None)
#
Link.clear_store("servicemenu")
target_iline = re.sub("\\_\\_\\w+\\_\\_", "", target_iline)
redirect_request = PredefinedHttpRequest()
redirect_request.set_module("output")
redirect_request.set_service("http")
redirect_request.set_action("done")
redirect_request.set_parameter_chained("title", L10n.get("pas_http_user_logout"))
redirect_request.set_parameter_chained("message", L10n.get("pas_http_user_done_logout"))
redirect_request.set_parameter_chained("target_iline", target_iline)
self.request.redirect(redirect_request)
示例6: execute
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute(self):
#
"""
Executes the processor.
:since: v0.1.00
"""
if (self.form is None or (not self.validate_settings(self.settings))): raise ValueException("Processor is not configured")
lang = (self.settings['email_lang']
if ("email_lang" in self.settings) else
L10n.get_instance().get_lang()
)
sender = (InputFilter.filter_control_chars(self.form.get_input(self.settings['email_sender_field_name']))
if ("email_sender_field_name" in self.settings) else
None
)
subject = (InputFilter.filter_control_chars(self.form.get_input(self.settings['email_subject_field_name']))
if ("email_subject_field_name" in self.settings) else
self.settings['email_subject_title']
)
if (subject is None or len(subject.strip()) < 1): raise ValueException("Given e-mail subject is invalid")
content_list = [ ]
titles = self.settings.get("form_field_titles", { })
for field_name in self.settings['email_content_field_names']:
#
value = InputFilter.filter_control_chars(self.form.get_input(field_name))
content_list.append("{0}:\n{1}".format((titles[field_name] if (field_name in titles) else field_name),
value
)
)
#
content = "\n\n".join(content_list)
DatabaseTasks.get_instance().add("dNG.pas.http.Form.sendEMail.{0}".format(Binary.str(hexlify(urandom(16)))),
"dNG.pas.http.Form.sendEMail",
1,
lang = lang,
sender = sender,
subject = subject,
content = content
)
示例7: execute_register
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute_register(self, is_save_mode = False):
"""
Action for "register"
:since: v0.2.00
"""
source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()
self._execute_register(source_iline = source_iline,
target_iline = target_iline,
is_save_mode = is_save_mode
)
示例8: execute_delete
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute_delete(self):
#
"""
Action for "delete"
:since: v0.1.00
"""
form_field_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_field_id", "")).strip()
form_field_entry_position = InputFilter.filter_int(self.request.get_dsd("oform_field_entry_position", -1))
if (form_field_entry_position > -1):
#
form_store = self._get_form_store()
form_store_dict = form_store.get_value_dict()
form_store_field_id = "form_api_dynamic_{0}".format(form_field_id)
entry_list = form_store_dict.get(form_store_field_id, [ ])
if (len(entry_list) > form_field_entry_position): del(entry_list[form_field_entry_position])
form_store_dict[form_store_field_id] = entry_list
form_store.set_value_dict(form_store_dict)
#
redirect_request = PredefinedHttpRequest()
redirect_request.set_module(self.request.get_module())
redirect_request.set_service(self.request.get_service())
redirect_request.set_action("get")
redirect_request.set_dsd_dict(self.request.get_dsd_dict())
self.request.redirect(redirect_request)
示例9: execute_get
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute_get(self):
#
"""
Action for "get"
:since: v0.1.00
"""
if (not self.response.is_supported("dict_result_renderer")): raise IOException("Unsupported response object for action")
form_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_id"))
form_field_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_field_id"))
try: form_store = Processor.load_form_store_id(form_id)
except NothingMatchedException as handled_exception: raise TranslatableException("core_access_denied", 403, _exception = handled_exception)
self._handle_get_choices(form_store, form_field_id)
示例10: get_app_configuration
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def get_app_configuration(self, api_version, template_type, client_details):
"""
Returns ApiEndpoint settings based on the given API version.
:param api_version: API version requested
:param template_type: Template type requested by the client
:param client_details: JSON encoded client details
:return: (dict) ApiEndpoint settings
:since: v0.2.00
"""
if (template_type == ""): template_type = "ten_foot_web"
template_type = "leanback_{0}".format(InputFilter.filter_control_chars(template_type).strip())
session = Session.load()
if (session.get("mp.leanback.user_agent") != self.client_user_agent):
session.set("mp.leanback.access_granted", True)
session.set("mp.leanback.user_agent", self.client_user_agent)
session.set("mp.leanback.template_type", template_type)
session.save()
#
url_parameters = { "m": "mp", "s": "leanback", "a": "dashboard", "uuid": session.get_uuid() }
url = Link.get_preferred("upnp").build_url(Link.TYPE_ABSOLUTE_URL, url_parameters)
return JsonResource().data_to_json({ "url": url })
示例11: _get_form_store
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def _get_form_store(self):
#
"""
Returns the form store in use for this dynamic field.
:return: (object) The form store in use for this dynamic field
:since: v0.1.00
"""
form_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_id"))
return FormProcessor.load_form_store_id(form_id)
示例12: _get_form_field_list
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def _get_form_field_list(self):
#
"""
Returns the content of the form store for this dynamic field.
:return: (dict) Content of the form store for this dynamic field
:since: v0.1.00
"""
form_field_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_field_id"))
form_value_dict = self._get_form_store().get_value_dict()
return form_value_dict.get("form_api_dynamic_{0}".format(form_field_id), [ ])
示例13: cookies
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def cookies(self):
"""
Returns request cookies.
:return: (dict) Request cookie name as key and value
:since: v1.0.0
"""
_return = { }
cookies = Header.get_field_list_dict(InputFilter.filter_control_chars(self.get_header("Cookie")), ";", "=")
for cookie in cookies: _return[cookie['key']] = cookie['value']
return _return
示例14: execute_reply
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def execute_reply(self, is_save_mode = False):
#
"""
Action for "reply"
:since: v0.1.00
"""
# pylint: disable=star-args
pid = InputFilter.filter_file_path(self.request.get_dsd("dpid", ""))
source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()
if (source_iline == ""): source_iline = "m=discuss;dsd=dpid+{0}".format(Link.encode_query_value(pid))
if (target_iline == ""): target_iline = "m=discuss;dsd=dpid+__id_d__"
self._execute_new("reply",
pid = pid,
source_iline = source_iline,
target_iline = target_iline,
is_save_mode = is_save_mode
)
示例15: get_view
# 需要导入模块: from dNG.data.text.input_filter import InputFilter [as 别名]
# 或者: from dNG.data.text.input_filter.InputFilter import filter_control_chars [as 别名]
def get_view(self):
"""
Action for "view"
:since: v1.0.0
"""
cid = InputFilter.filter_file_path(self.request.get_parameter("cid", ""))
source_iline = InputFilter.filter_control_chars(self.request.get_parameter("source", "")).strip()
L10n.init("pas_http_core_contentfile")
Settings.read_file("{0}/settings/pas_http_contentfiles.json".format(Settings.get("path_data")))
contentfiles = Settings.get("pas_http_contentfiles_list", { })
if (type(contentfiles) is not dict): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)
if (source_iline != ""):
if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.css")
Link.set_store("servicemenu",
Link.TYPE_RELATIVE_URL,
L10n.get("core_back"),
{ "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
icon = "mini-default-back",
priority = 7
)
#
if (cid not in contentfiles
or "title" not in contentfiles[cid]
or "filepath" not in contentfiles[cid]
): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)
file_content = FileContent.read(contentfiles[cid]['filepath'])
if (file_content is None): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)
if (path.splitext(contentfiles[cid]['filepath'])[1].lower() == ".ftg"): file_content = FormTags.render(file_content)
content = { "title": contentfiles[cid]['title'],
"content": file_content
}
self.response.init()
self.response.page_title = contentfiles[cid]['title']
self.response.add_oset_content("core.simple_content", content)