本文整理汇总了Python中org.apache.commons.lang.StringEscapeUtils类的典型用法代码示例。如果您正苦于以下问题:Python StringEscapeUtils类的具体用法?Python StringEscapeUtils怎么用?Python StringEscapeUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringEscapeUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setMultiDescription
def setMultiDescription(self, tfPackageJson, descriptionValue):
if descriptionValue is None:
self.log.info("No description found. Aborting set description shadow...")
tfPackageJson.put("dc:description.1.text", "")
tfPackageJson.put("dc:description.1.shadow", "")
tfPackageJson.put("dc:description.1.type", "full")
return
else:
## no tags are added to wysiwyg until user interacts with wysiwyg editor
unescapedDescription = ""
escapedDescription = ""
rawDescription = StringUtils.defaultString("%s" % descriptionValue)
## sanitize the incoming description
self.log.debug("raw deprecated description is: %s" % rawDescription)
sanitizedDescription = OwaspSanitizer.sanitizeHtml("dc:description.1.text", rawDescription)
if (sanitizedDescription):
# not completely accurate for checking for tags but ensures a style consistent with wysiwyg editor
if re.search("^<p>.*</p>|^<p>.*<\/p>", sanitizedDescription):
## deprecated description may be unescaped or escaped already - so ensure both cases covered
unescapedDescription = StringEscapeUtils.unescapeHtml("%s" % sanitizedDescription)
escapedDescription = OwaspSanitizer.escapeHtml("%s" % sanitizedDescription)
else:
unescapedDescription = StringEscapeUtils.unescapeHtml("<p>%s</p>" % sanitizedDescription)
escapedDescription = OwaspSanitizer.escapeHtml("<p>%s</p>" % sanitizedDescription)
self.log.info("relevant unescaped description is: %s" % unescapedDescription)
self.log.info("relevant escaped description is: %s" % escapedDescription)
tfPackageJson.put("dc:description.1.text", unescapedDescription)
tfPackageJson.put("dc:description.1.shadow", escapedDescription)
tfPackageJson.put("dc:description.1.type", "full")
self.log.debug("Removing deprecated 'dc:description' key...")
tfPackageJson.remove("dc:description")
self.log.debug(
"Completed migrating 'dc:description' to dc:description.1.text|shadow" % tfPackageJson)
示例2: __init__
def __init__(self):
print "formData=%s" % formData
result = "{}"
func = formData.get("func")
oid = formData.get("oid")
if func != "set-package-title":
nodeId = formData.get("nodeId")
nodePath = self.__getNodePath(formData.get("parents"), nodeId)
originalPath = "manifest//%s" % nodeId
self.__object = Services.getStorage().getObject(oid)
sourceId = self.__object.getSourceId()
payload = self.__object.getPayload(sourceId)
self.__manifest = JsonConfigHelper(payload.open())
payload.close()
if func == "set-package-title":
title = formData.get("title")
self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
self.__saveManifest()
if func == "rename":
title = formData.get("title")
self.__manifest.set("%s/title" % nodePath, title)
self.__saveManifest()
elif func == "move":
refNodeId = formData.get("refNodeId")
refNodePath = self.__getNodePath(formData.get("refParents"),
formData.get("refNodeId"));
moveType = formData.get("type")
if moveType == "before":
self.__manifest.moveBefore(originalPath, refNodePath)
elif moveType == "after":
self.__manifest.moveAfter(originalPath, refNodePath)
elif moveType == "inside":
self.__manifest.move(originalPath, nodePath)
self.__saveManifest()
elif func == "update":
title = StringEscapeUtils.escapeHtml(formData.get("title"))
hidden = formData.get("hidden")
hidden = hidden == "true"
self.__manifest.set("%s/title" % nodePath, title)
self.__manifest.set("%s/hidden" % nodePath, str(hidden))
self.__saveManifest()
result = '{ title: "%s", hidden: "%s" }' % (title, hidden)
self.__object.close()
writer = response.getPrintWriter("text/plain; charset=UTF-8")
writer.println(result)
writer.close()
示例3: handle_data
def handle_data(self, data):
# ~ print("Data :", data)
d = " ".join(data.split())
if d:
# ~ print ("This is real: ", d)
if self.current_tag == "span":
d = map2(d)
# ~ if d in ["checked", "unchecked"]:
# ~ print "Do yes/no, radio buttons, checkboxes stuff, how many spans?"
if d in self.contacts:
# ~ print "We need to process %s " % self.contacts[d]
# if span has interesting string, trigger recording next tr
self.nexts["td"] = True
self.current_contact = self.contacts[d]
if d in "Select the appropriate re-use condition for this research data":
print "Hit: collection-details-access-level but different, skip for now"
if d in "Indicate an anticipated number of users of this data":
print "Hit: exp-number-users,skip for now"
if d in self.simple_fields:
# ~ print "Simle field, the content of the next cell need to be packed"
self.current_field["name"] = self.simple_fields[d]
self.current_field["type"] = "simple"
self.nexts["td"] = True
## the if-else block is not useful if field names and values are in different cells
## it is useful when one next to each other
# if self.leading:
# self.current_key = d
# #~ print "create key %s" % self.current_key
# self.jobj[self.current_key] = ""
# else:
# #~ print "save value [ %s ] to %s" % (data, self.current_key)
# self.jobj[self.current_key] = d
if self.nexts["p"] and self.start_push:
self.stacks.append(StringEscapeUtils.escapeHtml(d))
示例4: getContent
def getContent(self, oid, metadata):
# Get the object
object = Services.getStorage().getObject(oid)
if object is None:
return ""
# Get the preview/source payload
pid = metadata.getFirst("preview")
if pid is None:
pid = object.getSourceId()
if pid is None:
return ""
payload = object.getPayload(object.getSourceId())
if payload is None:
return ""
# Stream the content out to string
out = ByteArrayOutputStream()
IOUtils.copy(payload.open(), out)
payload.close()
string = out.toString("UTF-8")
return "<pre>" + StringEscapeUtils.escapeHtml(string) + "</pre>"
示例5: escapeXml
def escapeXml(self, text):
return StringEscapeUtils.escapeXml(text)
示例6: getMeta
def getMeta(self, metaName):
return StringEscapeUtils.escapeHtml(self.vc("formData").get(metaName, self.__manifest.getString(None, [metaName])))
示例7: getPackageTitle
def getPackageTitle(self):
return StringEscapeUtils.escapeHtml(self.vc("formData").get("title", self.__manifest.getTitle()))
示例8: getFormData
def getFormData(self, field):
return StringEscapeUtils.escapeHtml(self.vc("formData").get(field, ""))
示例9: escapeHtml
def escapeHtml(self, value):
if value:
return StringEscapeUtils.escapeHtml(value) or ""
return ""
示例10: encodeXml
def encodeXml(self, string):
return StringEscapeUtils.escapeXml(string)
示例11: getMeta
def getMeta(self, metaName):
return StringEscapeUtils.escapeHtml(formData.get(metaName, self.__manifest.get(metaName)))
示例12: getRequestData
def getRequestData(self, field):
return StringEscapeUtils.escapeHtml(self.__requestData.getString("", [field]))
示例13: getText
def getText(self):
return StringEscapeUtils.escapeHtml(self.__metadata.get("user_agreement_text"))
示例14: __activate__
def __activate__(self, context):
self.velocityContext = context
auth = context["page"].authentication
if auth.is_logged_in():
self.fd = self.vc("formData").get
print "formData=%s" % self.vc("formData")
result = "{}"
func = self.fd("func")
oid = self.fd("oid")
if func != "update-package-meta":
nodeId = self.fd("nodeId")
nodePath = self.__getNodePath(self.fd("parents"), nodeId)
originalPath = "manifest//%s" % nodeId
self.__object = Services.getStorage().getObject(oid)
sourceId = self.__object.getSourceId()
payload = self.__object.getPayload(sourceId)
self.__manifest = JsonConfigHelper(payload.open())
payload.close()
if func == "update-package-meta":
print "********* update-package-meta ***************"
metaList = list(self.vc("formData").getValues("metaList"))
for metaName in metaList:
value = self.fd(metaName)
self.__manifest.set(metaName, value)
#title = formData.get("title")
#self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
self.__saveManifest()
if func == "rename":
title = self.fd("title")
self.__manifest.set("%s/title" % nodePath, title)
self.__saveManifest()
elif func == "move":
refNodeId = self.fd("refNodeId")
refNodePath = self.__getNodePath(self.fd("refParents"),
self.fd("refNodeId"));
moveType = self.fd("type")
if moveType == "before":
self.__manifest.moveBefore(originalPath, refNodePath)
elif moveType == "after":
self.__manifest.moveAfter(originalPath, refNodePath)
elif moveType == "inside":
self.__manifest.move(originalPath, nodePath)
self.__saveManifest()
elif func == "update":
title = StringEscapeUtils.escapeHtml(self.fd("title"))
hidden = self.fd("hidden")
hidden = hidden == "true"
self.__manifest.set("%s/title" % nodePath, title)
self.__manifest.set("%s/hidden" % nodePath, str(hidden))
#if self.__manifest.get("%s/id" % nodePath) is None:
# print "blank node!"
self.__saveManifest()
result = '{ title: "%s", hidden: "%s" }' % (title, hidden)
elif func == "delete":
title = self.__manifest.get("%s/title" % nodePath)
if title:
self.__manifest.removePath(nodePath)
self.__saveManifest()
else:
title = "Untitled"
result = '{ title: "%s" }' % title
self.__object.close()
else:
result = '{ "status": "error", "message": "Only registered users can access this API" }'
writer = self.vc("response").getPrintWriter("text/plain; charset=UTF-8")
writer.println(result)
writer.close()
示例15: unescapeHtml
def unescapeHtml(self, text):
return StringEscapeUtils.unescapeHtml(text)