We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Badly formed "mustache" mail merge fields raise exception NullPointerException


Aspose.Words 15.9

A malformed "mustache" mailmerge field (such as missing one or both curly braces at the end) causes a NullPointerException.

E.g. a document like this:-
Forename {{FORENAME} /****** NOTICE only 1 closing } ******/
Surname {{SURNAME}}

Test cases:-

package testasposewords;
import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.MailMerge;

public class TestAsposeWords {

public static void main(String[] args) throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder (doc);
builder.writeln ("Forename {{FORENAME}"); /****** NOTICE only 1 closing } ******/
builder.writeln ("Surname {{SURNAME}}");
MailMerge mm = doc.getMailMerge();
mm.setUseNonMergeFields(true);
String fieldNames[] = {"FORENAME","SURNAME"};
String values[] = {"Jon","Smith"};
mm.execute(fieldNames, values);
doc.save("c:\\temp\\1.docx");
}
}

Exception in thread "main" java.lang.NullPointerException
at com.aspose.words.zzYYB.zzY(Unknown Source)
at com.aspose.words.zzYYB.zzYZy(Unknown Source)
at com.aspose.words.zzYYB.zzYZA(Unknown Source)
at com.aspose.words.zzYYB.zzq(Unknown Source)
at com.aspose.words.MailMerge.zzUt(Unknown Source)
at com.aspose.words.MailMerge.zzZ(Unknown Source)
at com.aspose.words.MailMerge.execute(Unknown Source)
at testasposewords.TestAsposeWords.main(TestAsposeWords.java:18)


Also, although I don't have a test case, using an XML datasource causes this error with malformed mailmerge fields:-

Exception in thread "main" java.lang.NegativeArraySizeException
at asposewobfuscated.zz62.zzX(Unknown Source)
at com.aspose.words.zzYYB.zzY(Unknown Source)
at com.aspose.words.zzYYB.zzYZy(Unknown Source)
at com.aspose.words.zzYYB.zzYZA(Unknown Source)
at com.aspose.words.zzYYB.zzq(Unknown Source)
at com.aspose.words.MailMerge.zzUt(Unknown Source)
at com.aspose.words.MailMerge.zzZ(Unknown Source)
at com.aspose.words.MailMerge.executeWithRegions(Unknown Source)
at uk.gov.calderdale.aspose.words.CommandMailMerge.merge(CommandMailMerge.java:145)
at uk.gov.calderdale.aspose.words.AsposeWords.main(AsposeWords.java:50)


Hi Jonathan,

Thanks for your inquiry.
I have tested the scenario and have managed to reproduce the same issue
at my side. For the sake of correction, I have logged this problem in
our issue tracking system as WORDSNET-12537. I have linked this forum
thread to the same issue and you will be notified via this forum thread
once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-12537) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.