Anti-samy code will avoid the onclick in anchor link - antisamy

I am using anti-samy 1.5.2 version for converting my html to safe html.
Now i am giving a following code to anti-samy scan method
gmail.com
but anti samy will convert this into following
javaEra.com
due to this my onclick is not working in my application
So I want same code which i have given to antisamy
Can any one help me?
Here my anti samy policy file for anchor tag
<tag name="a" action="validate">
<!-- onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid -->
<attribute name="href"/>
<attribute name="nohref">
<regexp-list>
<regexp name="anything"/>
</regexp-list>
</attribute>
<attribute name="rel">
<literal-list>
<literal value="nofollow"/>
</literal-list>
</attribute>
<attribute name="name"/>
<attribute name="target" onInvalid="filterTag">
<literal-list>
<literal value="_blank"/>
<literal value="_top"/>
<literal value="_self"/>
<literal value="_parent"/>
</literal-list>
</attribute>
</tag>

At finally I got the solution for this one: just add folloing attribute to anchor tag
In above code replace like below
<tag name="a" action="validate">
<!-- onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid -->
<attribute name="href"/>
<attribute name="nohref">
<regexp-list>
<regexp name="anything"/>
</regexp-list>
</attribute>
<attribute name="rel">
<literal-list>
<literal value="nofollow"/>
</literal-list>
</attribute>
<attribute name="name"/>
<attribute name="target" onInvalid="filterTag">
<literal-list>
<literal value="_blank"/>
<literal value="_top"/>
<literal value="_self"/>
<literal value="_parent"/>
</literal-list>
</attribute>
<attribute name="onclick">
<regexp-list>
<regexp name="anything"/>
</regexp-list>
</attribute>
</tag>
itys working now.

Related

How to parse multiple XML files into one data frame using R? [duplicate]

I am trying to parse/read the multiple xml files from my current data and try to combine them together.
And my sample xml file is like this:
<ApplicationResponse>
<Service Name="AlternativeCreditAttributes">
<Categories>
<Category Name="Default">
<Attributes>
<Attribute Name="ACA_ACH_NSF_12M" Value="0" />
<Attribute Name="ACA_ACH_NSF_18M" Value="0" />
<Attribute Name="ACA_ACH_NSF_24M" Value="0" />
<Attribute Name="ACA_ACH_NSF_3M" Value="0" />
<Attribute Name="ACA_ACH_NSF_6M" Value="0" />
<Attribute Name="ACA_ACH_NSF_9M" Value="0" />
<Attribute Name="ACA_ACH_NSF_AMT_12M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_18M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_24M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_3M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_6M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_9M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_EVER" Value="600" />
<Attribute Name="ACA_ACH_NSF_EVER" Value="2" />
<Attribute Name="ACA_ACH_NSF_MONTHS_SINCE_NEWEST" Value="41" />
<Attribute Name="ACA_ACH_NSF_MONTHS_SINCE_OLDEST" Value="41" />
</Attributes>
</Category>
</Categories>
</Service>
</ApplicationResponse>
I have successfully pulled one single file based on the following code:
doc<-read_xml(Data$XMLResponse[1])
# setNames(data.frame(
cols<- xml_attr(xml_find_all(doc, "//Attribute"), "Name")
rows<- xml_attr(xml_find_all(doc, "//Attribute"), "Value")
# ),
out <- data.frame(rows, row.names = cols)
out
But when I tried to use lapply to pull multiple files base on this answer, I met the Error on working directory.
Error: 'NA' does not exist in current working directory
Below is the code I use. Please let me know if you know the issue or if you need any details on this problem. Thanks in advance.
df_list <- lapply(Data$XMLResponse, function(f) {
doc <- read_xml(f)
setNames(data.frame(
xml_attr(xml_find_all(doc, "//Attribute"), "Name"),
xml_attr(xml_find_all(doc, "//Attribute"), "Value")
),c("Name", f))
})
Here is an approach that uses a for() loop to collect all of the values from each xml file that you have stored within Data$XMLResponse. Code assumes every xml file has exactly the same length of "Attributes" in the same order.
library(xml2)
#create a blank list
datalist = list()
#loop through your column of xml responses to extract the values you want.
for(i in 1:length(Data$XMLResponse)){
temp_vals<-read_xml(Data$XMLResponse[i])
temp_vals<-xml_attr(xml_find_all(temp_vals, "//Attribute"), "Value")
#assign these values to your data list
datalist[[i]]<-temp_vals
}
#bind the data from the xml files together
your_data = do.call(rbind, datalist)
Then get column names:
your_column_names<-xml_attr(xml_find_all(Data$XMLResponse[1], "//Attribute"), "Name")
doc<-setNames(data.frame(matrix(ncol = length(your_column_names), nrow = 0)), your_column_names)
And then use rbind() to bind your data with your column names
rbind(doc,your_data)

odoo, qweb: I like to replace attribute's value in odoo report

In odoo, qweb report. I have created an inherited report whith objective to change t-call attribute value from internal_layout to external layout. i have used the next code:
<template id="!!!!!!!!!!!!" inherit_id="!!!!!!!!!!!!!">
<xpath expr="//t[#t-call='web.internal_layout']" position="attributes">
<attribute name="attrs">{'t-call':'web.external_layout'}</attribute>
</xpath>
</template>
This code did not work, I wonder if there is a way to insert sub part of the same report.
<template id="!!!!!!!!!!!!!!!!!!" inherit_id="!!!!!!!!!!!">
<xpath expr="//t[#t-call='web.internal_layout']" position="replace">
<t t-call='web.external_layout'>
insert here original sub report
</t>
</xpath>
</template>
Operation doable by this small changment !
<data>
<template id="!!!!!!!!!!" inherit_id="!!!!!!!!!!!!!!!!!">
<xpath expr="//t[#t-call='web.internal_layout']" position="attributes">
<attribute name="t-call">web.external_layout</attribute>
</xpath>
</template>
</data>
If your views is for multiple object, like contains:
<t t-set="o" t-value="o.with_context({'lang':o.customer_id.lang})" />
you must add others attributes modification:
<xpath expr="//t[#t-call='web.internal_layout']" position="attributes">
<attribute name="t-call">web.external_layout</attribute>
<attribute name="t-foreach">docs</attribute>
<attribute name="t-as">o</attribute>
</xpath>

working directory error when read multiple xml files in R and combine the data

I am trying to parse/read the multiple xml files from my current data and try to combine them together.
And my sample xml file is like this:
<ApplicationResponse>
<Service Name="AlternativeCreditAttributes">
<Categories>
<Category Name="Default">
<Attributes>
<Attribute Name="ACA_ACH_NSF_12M" Value="0" />
<Attribute Name="ACA_ACH_NSF_18M" Value="0" />
<Attribute Name="ACA_ACH_NSF_24M" Value="0" />
<Attribute Name="ACA_ACH_NSF_3M" Value="0" />
<Attribute Name="ACA_ACH_NSF_6M" Value="0" />
<Attribute Name="ACA_ACH_NSF_9M" Value="0" />
<Attribute Name="ACA_ACH_NSF_AMT_12M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_18M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_24M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_3M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_6M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_9M" Value="" />
<Attribute Name="ACA_ACH_NSF_AMT_EVER" Value="600" />
<Attribute Name="ACA_ACH_NSF_EVER" Value="2" />
<Attribute Name="ACA_ACH_NSF_MONTHS_SINCE_NEWEST" Value="41" />
<Attribute Name="ACA_ACH_NSF_MONTHS_SINCE_OLDEST" Value="41" />
</Attributes>
</Category>
</Categories>
</Service>
</ApplicationResponse>
I have successfully pulled one single file based on the following code:
doc<-read_xml(Data$XMLResponse[1])
# setNames(data.frame(
cols<- xml_attr(xml_find_all(doc, "//Attribute"), "Name")
rows<- xml_attr(xml_find_all(doc, "//Attribute"), "Value")
# ),
out <- data.frame(rows, row.names = cols)
out
But when I tried to use lapply to pull multiple files base on this answer, I met the Error on working directory.
Error: 'NA' does not exist in current working directory
Below is the code I use. Please let me know if you know the issue or if you need any details on this problem. Thanks in advance.
df_list <- lapply(Data$XMLResponse, function(f) {
doc <- read_xml(f)
setNames(data.frame(
xml_attr(xml_find_all(doc, "//Attribute"), "Name"),
xml_attr(xml_find_all(doc, "//Attribute"), "Value")
),c("Name", f))
})
Here is an approach that uses a for() loop to collect all of the values from each xml file that you have stored within Data$XMLResponse. Code assumes every xml file has exactly the same length of "Attributes" in the same order.
library(xml2)
#create a blank list
datalist = list()
#loop through your column of xml responses to extract the values you want.
for(i in 1:length(Data$XMLResponse)){
temp_vals<-read_xml(Data$XMLResponse[i])
temp_vals<-xml_attr(xml_find_all(temp_vals, "//Attribute"), "Value")
#assign these values to your data list
datalist[[i]]<-temp_vals
}
#bind the data from the xml files together
your_data = do.call(rbind, datalist)
Then get column names:
your_column_names<-xml_attr(xml_find_all(Data$XMLResponse[1], "//Attribute"), "Name")
doc<-setNames(data.frame(matrix(ncol = length(your_column_names), nrow = 0)), your_column_names)
And then use rbind() to bind your data with your column names
rbind(doc,your_data)

Alfresco disable full text indexing on specific content model

Using Alfresco 4.2 or 5.0, how do you disable full text indexing on a content-model basis?
Here is an example content model, what do you change specifically (i.e. do not reference the index control aspect without how to actually use it with a content model).
<model name="my:textdoc" xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<imports>
<import prefix="d" uri="http://www.alfresco.org/model/dictionary/1.0" />
<import prefix="cm" uri="http://www.alfresco.org/model/content/1.0" />
</imports>
<namespaces>
<namespace prefix="my"
uri="http://www.notarealurl.xyz/model/my/1.0" />
</namespaces>
<types>
<type name="my:securetextdoc">
<title>text docs with keyword searching, but not content searching</title>
<parent>cm:content</parent>
<properties>
<property name="my:securekeywords">
<title>custom key word text field</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
<mandatory-aspects>
<!-- <aspect>cm:dublincore</aspect> -->
<aspect>cm:versionable</aspect>
</mandatory-aspects>
</type>
</types>
FINAL ANSWER
<model name="my:textdoc" xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<imports>
<import prefix="d" uri="http://www.alfresco.org/model/dictionary/1.0" />
<import prefix="cm" uri="http://www.alfresco.org/model/content/1.0" />
</imports>
<namespaces>
<namespace prefix="my"
uri="http://www.notarealurl.xyz/model/my/1.0" />
</namespaces>
<types>
<type name="my:securetextdoc">
<title>text docs with keyword searching, but not content searching</title>
<parent>cm:content</parent>
<properties>
<property name="my:securekeywords">
<title>custom key word text field</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
<mandatory-aspects>
<!-- <aspect>cm:dublincore</aspect> -->
<aspect>my:doNotIndexContentControl</aspect>
<aspect>cm:versionable</aspect>
</mandatory-aspects>
</type>
</types>
<aspects>
<aspect name="my:doNotIndexContentControl">
<title>Do Not Index Control</title>
<parent>cm:indexControl</parent>
<overrides>
<property name="cm:isIndexed">
<default>true</default>
</property>
<property name="cm:isContentIndexed">
<default>false</default>
</property>
</overrides>
</aspect>
</aspects>
</model>
Important Note: If you get "Source node class has no callback" errors, this is related to changing the content model and then trying to update (likely versionable) existing content. No known workaround, but this is unrelated to index control options.
You can achieve this by defining a new aspect that extends cm:indexControl like so:
<aspect name="my:doNotIndexContentControl">
<title>Do Not Index Control</title>
<parent>cm:indexControl</parent>
<overrides>
<property name="cm:isIndexed">
<default>true</default>
</property>
<property name="cm:isContentIndexed">
<default>false</default>
</property>
</overrides>
</aspect>
Note the overrides. The overridden property, cm:isContentIndexed, with default value set to false is key.
You then add this aspect as mandatory for the types which you do not wish to full text index the content. The full configuration options for cm:indexControl can be found in the documentation http://docs.alfresco.com/4.2/concepts/admin-indexes.html
Also, if you have existing content items that have already been indexed and you want those documents to no longer be indexed, you will need to do a full re-index.
This is covered in the Data Dictionary guide on the Alfresco wiki
All you need to do is all this to your model:
<index enabled="false" />
If you look at something like the Alfresco system model, you'll see several examples of that

How do I set a default value for an Aspect property in Alfresco?

How do I set a default value for an Aspect property in Alfresco? Would that be a constraint or is there an attribute on the property itself?
This is my property:
<constraint name="ac:Priority_Options" type="LIST">
<parameter name="allowedValues">
<list>
<value>Low</value>
<value>Medium</value>
<value>High</value>
</list>
</parameter>
</constraint>
<property name="ac:propPriority">
<title>Priority</title>
<type>d:text</type>
<multiple>false</multiple>
<constraints>
<constraint ref="ac:Priority_Options" />
</constraints>
</property>
As described in Additional Property Capabilities:
<property name="ac:propPriority">
<title>Priority</title>
<type>d:text</type>
<multiple>false</multiple>
<default>my default value</default> <!-- !! -->
<constraints>
<constraint ref="ac:Priority_Options" />
</constraints>
</property>

Resources