@@ -135,6 +135,7 @@ public NotificationHubJobStatus getJobStatus() {
135135 * @param value The Azure Notification Hubs job output container URI value to set.
136136 */
137137 public void setOutputContainerUri (String value ) {
138+ // Keep the raw URI and strip the CDATA
138139 if (value .matches (CDATA_PATTERN )) {
139140 value = value .replaceAll (CDATA_PATTERN , "" );
140141 }
@@ -151,7 +152,13 @@ public void setOutputContainerUri(String value) {
151152 * Sets the Azure Notification Hubs job file import URI.
152153 * @param value The Azure Notification Hubs job file import URI value to set.
153154 */
154- public void setImportFileUri (String value ) { importFileUri = value ; }
155+ public void setImportFileUri (String value ) {
156+ // Keep the raw URI and strip the CDATA
157+ if (value .matches (CDATA_PATTERN )) {
158+ value = value .replaceAll (CDATA_PATTERN , "" );
159+ }
160+ importFileUri = value ;
161+ }
155162
156163 /**
157164 * Gets the Azure Notification Hubs job failure message.
@@ -237,6 +244,8 @@ public String getXml() {
237244 if (this .jobType != null ) {
238245 buf .append ("<Type>" ).append (this .jobType .name ()).append ("</Type>" );
239246 }
247+
248+ // Wrap URIs in CDATA sections due to illegal XML characters
240249 if (this .outputContainerUri != null ) {
241250 String outputContainerUri = this .outputContainerUri ;
242251 if (!outputContainerUri .matches (CDATA_PATTERN )) {
@@ -245,7 +254,12 @@ public String getXml() {
245254 buf .append ("<OutputContainerUri>" ).append (outputContainerUri ).append ("</OutputContainerUri>" );
246255 }
247256 if (this .importFileUri != null ) {
248- buf .append ("<ImportFileUri>" ).append (this .importFileUri ).append ("</ImportFileUri>" );
257+ String importFileUri = this .importFileUri ;
258+ if (!importFileUri .matches (CDATA_PATTERN )) {
259+ importFileUri = "<![CDATA[" + importFileUri + "]]>" ;
260+ }
261+
262+ buf .append ("<ImportFileUri>" ).append (importFileUri ).append ("</ImportFileUri>" );
249263 }
250264 buf .append (XML_FOOTER );
251265 return buf .toString ();
0 commit comments