Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

facing problem with the xml elements markup tags

Avatar

Level 3

Hi All,

I am generating the below code in the xml using javascript

<Validation>

<Field>Firstname-Y</Field>

<Message>Didnt  Fill  FirstName</Message>

</Validation>

<Validation>

<Field>Secondname-Y</Field>

<Message>Didnt  Fill  SecondName</Message>

</Validation>

<Validation>

<Field>Address-Y</Field>

<Message>Didnt  Fill  Address</Message>

</Validation>

<Validation>

<Field>Comments-Y</Field>

<Message>Didnt  Fill Comments</Message>

</Validation>

When the xml is generated,I all the markups "<" and ">" are converted into &lt; and &gt;

The code looks like this

&lt;Validation&gt;

&lt;Field&gt;Firstname-Y&lt;/Field&gt;

&lt;Message&gt;Didnt Fill FirstName&lt;/Message&gt;

&lt;/Validation&gt;

&lt;Validation&gt;

&lt;Field&gt;Secondname-Y&lt;/Field&gt;

&lt;Message&gt;Didnt Fill SecondName&lt;/Message&gt;

&lt;/Validation&gt;

&lt;Validation&gt;

&lt;Field&gt;Address-Y&lt;/Field&gt;

&lt;Message&gt;Didnt Fill Address&lt;/Message&gt;

&lt;/Validation&gt;

&lt;Validation&gt;

&lt;Field&gt;Comments-Y&lt;/Field&gt;

&lt;Message&gt;Didnt Fill Comments&lt;/Message&gt;

&lt;/Validation&gt;

How to overcome this ?.I tried using the ascii equvalent and unicode equivalent for those two markups.But got the same result.

Please can anyone suggest how to get the symbols as it is in the generated xml.

Its very urgent requirement for me.

Thanks,

Manjula

6 Replies

Avatar

Former Community Member

Fix your javascript.

Post it here if you need help.

Avatar

Level 3

var errorarray=new Array();
var errormsgarry=new Array();
var c=0;
var msgbox="";
var strng="";
if(firstName.rawValue==null)
{
c=c+1;
errorarray[0]="Firstname-Y";
errormsgarry[0]="Didnt Fill FirstName";
msgbox="FirstName " + <br/>;
}
if(secondName.rawValue==null)
{
c=c+1;
errorarray[1]="Secondname-Y";
errormsgarry[1]="Didnt Fill SecondName";
msgbox= msgbox + "  SecondName " + <br/>;
}
if(Address.rawValue==null)
{
c=c+1;
errorarray[2]="Address-Y";
errormsgarry[2]="Didnt Fill Address";
msgbox= msgbox + "  Address " + <br/>;
}
if(Comments.rawValue==null)
{
c=c+1;
errorarray[3]="Comments-Y";
errormsgarry[3]="Didnt Fill Comments";
msgbox= msgbox + "  Comments" + <br/>;
}

if(c>0)
{
    var check=xfa.host.messageBox("Please enter the fields " + msgbox + " still you want to continue ?","Alert","3","2");
        if(check==3)
        {
        xfa.host.messageBox("Please fill the fields");
        }
        else
        {
       
            for(var i=0;i<errorarray.length;i++)
            {
           
                if(errorarray[i]!=null)
                {
               
                strng= strng + String.fromCharCode(60)+"Validation"+String.fromCharCode(62)+String.fromCharCode(60)+"Field"+String.fromCharCode(62) + errorarray[i]
+String.fromCharCode(60) +"\/Field"+String.fromCharCode(62)+String.fromCharCode(60)+"Message"+String.fromCharCode(62)+ errormsgarry[i] +String.fromCharCode(60)+"\/Message"+String.fromCharCode(62)+String.fromCharCode(60)+"\/Validation"+String.fromCharCode(62);
               
                }
       
            }
                xfa.host.messageBox(strng);
                fnameValid.rawValue=strng;
                EmailSubmitButton1.execEvent("click");
        }

}
else
{
errorarray.length=0;
errormsgarry.length=0;
EmailSubmitButton1.execEvent("click");
}


This is my javascript code and I am facing problem in the section

        strng= strng +  String.fromCharCode(60)+"Validation"+String.fromCharCode(62)+String.fromCharCode(60)+"Field"+String.fromCharCode(62)  + errorarray[i]
+String.fromCharCode(60)  +"\/Field"+String.fromCharCode(62)+String.fromCharCode(60)+"Message"+String.fromCharCode(62)+  errormsgarry[i]  +String.fromCharCode(60)+"\/Message"+String.fromCharCode(62)+String.fromCharCode(60)+"\/Validation"+String.fromCharCode(62);

Avatar

Former Community Member

Nothing wrong there. What does EmailSubmitButton1.execEvent("click") look like?

Avatar

Level 3

like after concating the string,I am submitting the form by using the email submit button to generate an xml.

That generated xml will have "&lt" for "<" and "&gt" for ">" and my xml looks like this

&lt;Validation&gt;

&lt;Field&gt;Firstname-Y&lt;/Field&gt;

&lt;Message&gt;Didnt Fill FirstName&lt;/Message&gt;

&lt;/Validation&gt;

&lt;Validation&gt;

&lt;Field&gt;Secondname-Y&lt;/Field&gt;

&lt;Message&gt;Didnt Fill SecondName&lt;/Message&gt;

&lt;/Validation&gt;

&lt;Validation&gt;

&lt;Field&gt;Address-Y&lt;/Field&gt;

&lt;Message&gt;Didnt Fill Address&lt;/Message&gt;

&lt;/Validation&gt;

&lt;Validation&gt;

&lt;Field&gt;Comments-Y&lt;/Field&gt;

&lt;Message&gt;Didnt Fill Comments&lt;/Message&gt;

&lt;/Validation&gt;

which should be

<Validation>

<Field>Firstname-Y</Field>

<Message>Didnt  Fill  FirstName</Message>

</Validation>

<Validation>

<Field>Secondname-Y</Field>

<Message>Didnt  Fill  SecondName</Message>

</Validation>

<Validation>

<Field>Address-Y</Field>

<Message>Didnt  Fill  Address</Message>

</Validation>

<Validation>

<Field>Comments-Y</Field>

<Message>Didnt  Fill Comments</Message>

</Validation>

Thanks,

Manjula

Avatar

Former Community Member

There's nothing wrong with your javascript, nor the xml you're generating. The problem lies in injecting xml code into a text field and expecting Acrobat to simply pass it on to the xml string. Any other behaviour than the current would leave the form's application open to exploits.

Consider a scenario in which a form has a write-protected field called InterestRate ("admins only") and an open field called "Firstname".

A user could then enter the following into the Firstname field:

Paul</FirstName><InterestRate>0.02</InterestRate><FirstName>Paul

If Acrobat would behave the way you want it to, the following xml code would be generated:

<FirstName>Paul</FirstName><InterestRate>0.02</InterestRate><FirstName>Paul</FirstName>

Valid, well-formed and Voila! Paul just set his own interest rate by using xml injection.

I won't ask why you're generating validation messages and passing them along the form data, but you need to approach from a different direction. Either a) let the system receiving the e-mail generate the validation message or b) let that system transform the validation message back to valid xml.

Avatar

Level 3

Thanks for your reply,I got your point.I am new to livecycle so I dont have any idea of how to get the output for that scenario

Thanks,

Manjula