Changeset 33753


Ignore:
Timestamp:
2019-12-04T21:22:19+13:00 (4 years ago)
Author:
davidb
Message:

Made the change Dr Bainbridge wanted: in the two locations that metadata gets put into the csv_line_mmetadata under the associated metadata_name, the metadata_value first has any square brackets within it protected by being replaced with the html entity versions of it (not hex entities, but regular). This is to prevent conflict between unescaped square brackets that have special meaning and are specially handled when the GS3 runtime code processes meta, whereas literal square brackets in a meta value like dc.Title must be preserved as square brackets and not treated specially handled by the GS3 runtime code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/heritage-nz/collect/pdf-reports/perllib/plugins/MetadataCSVPlugin.pm

    r33020 r33753  
    211211           
    212212            my @within_md_vals = split(/${md_val_sep}/,$md_val);
    213             push (@{$csv_line_metadata{$md_name}}, @within_md_vals);
     213            #push (@{$csv_line_metadata{$md_name}}, @within_md_vals);
     214
     215            # protect square brackets in metadata values by hex entity encoding them
     216            # As unescaped square bracket chars in metadata
     217            # have special meaning in GS' Java runtime code
     218            my @escaped_within_md_vals = ();
     219            for my $meta_value (@within_md_vals) {
     220                $meta_value =~ s/\[/&\#091;/g;
     221                $meta_value =~ s/\]/&\#093;/g;
     222                push(@escaped_within_md_vals, $meta_value);
     223            }
     224            push (@{$csv_line_metadata{$md_name}}, @escaped_within_md_vals);
    214225
    215226#           foreach my $within_md_val (@within_md_vals) {
     
    218229            }
    219230            else {
    220             push (@{$csv_line_metadata{$md_name}}, $md_val);
     231            #push (@{$csv_line_metadata{$md_name}}, $md_val);
     232            # protect square brackets in metadata values by hex entity encoding them
     233            my $escaped_metadata_value = $md_val;
     234            $escaped_metadata_value =~ s/\[/&\#091;/g;
     235            $escpaed_metadata_value =~ s/\]/&\#093;/g;
     236            push (@{$csv_line_metadata{$md_name}}, $escaped_metadata_value);
    221237            }
    222238        }
Note: See TracChangeset for help on using the changeset viewer.