简体   繁体   中英

Invalid Character in base64 string with XML

I am getting an error that I'm sad to say that I don't know much about dealing with 64base strings. Currently I've tracked down this error to this line of code:

byte[] jobData = Convert.FromBase64String(base64JobData);

Here is my XML, that is being passed into the base64JobData but I can't seem to find anything that should throw this error.

<?xml version="1.0" encoding="utf-16"?>
<JobItem xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SiteServerItemShareCollection" JobName="0005_Hi" JobTargetResultId="2a59cf11-c58e-4cdc-80e8-7b4c70b940dc" JobId="5a79a30f-3250-4401-b181-f6e5f16fe5ef" JobItemType="NetworkShare" JobProcessWorkflowId="9834e3a5-b508-405f-ad5b-d8c9d1837982" Priority="1" CallbackConversationId="fb501b7b-cd43-4883-bbc7-5a356e1dd030" IsAudit="false" IsRemediation="false" IsArchive="true" IsPreview="false" ReportOnNonResponsiveData="false" CustodianId="00000000-0000-0000-0000-000000000000" IsCompleted="false" HasCredentials="true" MinSecondsBetweenAttempts="600" UseRedirectedAcquisition="false" IsSerialProcessing="false" CanPhoneHome="false" AgentGuid="00000000-0000-0000-0000-000000000000" DynamicIPLocality="false" TaskId="00000000-0000-0000-0000-000000000000">
<CollectionItemQueue ItemId="2a59cf11-c58e-4cdc-80e8-7b4c70b940dc" CollectionId="5a79a30f-3250-4401-b181-f6e5f16fe5ef" CollectionType="NetworkShare" Name="0005_Hi" ReferenceItemId="00000000-0000-0000-0000-000000000000" CollectionStatus="0">
  <AssetCollectionStartDate xsi:nil="true" />
  <PrescanStartDate xsi:nil="true" />
  <LastCollectedFileSize xsi:nil="true" />
  <NumberFilesCollected xsi:nil="true" />
  <FilesCollectedSize xsi:nil="true" />
  <CurrentFileSize xsi:nil="true" />
  <TotalPossibleFilesToCollect xsi:nil="true" />
  <TotalPossibleFileBytesToCollect xsi:nil="true" />
</CollectionItemQueue>
<RunCollectionPreScan>false</RunCollectionPreScan>
<FileTransferRetryDelayInSeconds>900</FileTransferRetryDelayInSeconds>
<FileTransferRetryAttempts>3</FileTransferRetryAttempts>
<AssetCollectionStartDate xsi:nil="true" />
<PrescanStartDate xsi:nil="true" />
<LastCollectedFileSize xsi:nil="true" />
<NumberFilesCollected xsi:nil="true" />
<FilesCollectedSize xsi:nil="true" />
<CurrentFileSize xsi:nil="true" />
<TotalPossibleFilesToCollect xsi:nil="true" />
<TotalPossibleFileBytesToCollect xsi:nil="true" />
<JobTargetName>\\10.10.200.222\Evidence</JobTargetName>
<JobTargetId>fd0d6e98-7227-4589-b578-a8f0a88955c2</JobTargetId>
<JobResultId>00000000-0000-0000-0000-000000000000</JobResultId>
<FiltersXML>&lt;Filter SystemFiles="false" UnusedDiskArea="false" VolumeSlack="false" CollectArchiveContentOnly="true" CollectEncryptedFiles="false" UsePhysicalDrives="false" UseSearchWithAgent="false" UseSearchWithServer="false" AutoDrillDown="false" CollectNoExtensionFiles="false" IncludeDeletedFiles="false" SmartFileIdentification="false" xmlns="http://FilterSchema" /&gt;</FiltersXML>
<ResponsiveFilePath>\\10.10.200.222\E$\Cases\Jobs\Test\2013-01-30 15.46.46\Item_10.10.200.222Evidence\1</ResponsiveFilePath>
<CollectionAttemptBeginTime xsi:nil="true" />
<CollectionAttemptEndTime xsi:nil="true" />
<CollectAsCredentials />
<Expiration>2013-03-01T15:46:45.797</Expiration>
<CollectionEncryption>
  <CollectionId>5a79a30f-3250-4401-b181-f6e5f16fe5ef</CollectionId>
  <EncryptionType>None</EncryptionType>
<CertificateId>00000000-0000-0000-0000-000000000000</CertificateId>
</CollectionEncryption>
</JobItem>

Is there a easy way to figure out what the offending character is in this xml string? or a tool that can help me find why I am getting this failure.

I think either your question may be confusing, or there is a mis-understanding of the function's behavior. This function is to convert FROM base64, so if you are feeding it the XML above, that will not work. The function is expecting a base64-encoded string.

Here is the link from MS - frombase64string

Which states, "Converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array."

Parameter string "s" - s is composed of base-64 digits, white-space characters, and trailing padding characters. The base-64 digits in ascending order from zero are the uppercase characters "A" to "Z", lowercase characters "a" to "z", numerals "0" to "9", and the symbols "+" and "/".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM