@@ -27,22 +27,22 @@ XML::Enc - XML Encryption
27
27
=head1 SYNOPSIS
28
28
29
29
my $decrypter = XML::Enc->new(
30
- {
31
- key => 't/sign-private.pem',
32
- no_xml_declaration => 1,
33
- },
34
- );
30
+ {
31
+ key => 't/sign-private.pem',
32
+ no_xml_declaration => 1,
33
+ },
34
+ );
35
35
$decrypted = $enc->decrypt($xml);
36
36
37
37
my $encrypter = XML::Enc->new(
38
- {
39
- cert => 't/sign-certonly.pem',
40
- no_xml_declaration => 1,
41
- data_enc_method => 'aes256-cbc',
42
- key_transport => 'rsa-1_5',
43
-
44
- },
45
- );
38
+ {
39
+ cert => 't/sign-certonly.pem',
40
+ no_xml_declaration => 1,
41
+ data_enc_method => 'aes256-cbc',
42
+ key_transport => 'rsa-1_5',
43
+
44
+ },
45
+ );
46
46
$encrypted = $enc->encrypt($xml);
47
47
48
48
=head1 METHODS
@@ -367,17 +367,20 @@ sub _decrypt_encrypted_node {
367
367
# Sooo.. parse_balanced_chunk breaks when there is a <xml version="1'>
368
368
# bit in the decrypted data and thus we have to remove it.
369
369
# We try parsing the XML here and if that works we get all the nodes
370
- my $fragment ;
371
- eval {
372
- $fragment = $parser -> load_xml(string => $decrypted_data )-> findnodes(' //*' )-> [0];
373
- };
374
- $fragment = $parser -> parse_balanced_chunk($fragment // $decrypted_data );
370
+ my $new = eval { $parser -> load_xml(string => $decrypted_data )-> findnodes(' //*' )-> [0]; };
371
+
372
+ if ($new ) {
373
+ $node -> addSibling($new );
374
+ $node -> unbindNode();
375
+ return ;
376
+ }
375
377
378
+ $decrypted_data = $parser -> parse_balanced_chunk($decrypted_data );
376
379
if (($node -> parentNode-> localname //' ' ) eq ' EncryptedID' ) {
377
- $node -> parentNode-> replaceNode($fragment );
380
+ $node -> parentNode-> replaceNode($decrypted_data );
378
381
return ;
379
382
}
380
- $node -> replaceNode($fragment );
383
+ $node -> replaceNode($decrypted_data );
381
384
return ;
382
385
}
383
386
0 commit comments