TriNetre - Archive for March 20, 2004

(no longer updated)



March 20, 2004
Naive MT way to export data
[Software] @ 09:02 PM

MovableType has a very simple (naive?) template for exporting data in the entries. This creates problems for comments that are PGP signed. MT uses a sequence '-----' to separate blocks of comments (and its details like IP, date, author, email etc.). It then uses a simpler Perl code to parse the data when importing the data (comments in code are mine):

my $SUB_SEP = ('-' x 5); #line 3038 of MT/App/CMS.pm
my($meta, @pieces) = split /$SUB_SEP/; #line 3092 of MT/App/CMS.pm

What all this simplicity creates is ambiguity when the export/import system encounters PGP signed comments. In a PGP signed text, the sequence '-----' is used to separate various parts of the text like the beginning of the signed text, the start of the signature and the end of the signed text. When the import system encounters the '-----' of the PGP signed text, it assumes that this indicates the end of one comment block and the beginning of the next. This throws the whole system into disarray.

There is no easy to way to side step this problem without hacking the core MT file CMS.pm (version 2.661).

Solution 1 is to change the line 3092 of MT/App/CMS.pm file mentioned above to

my($meta, @pieces) = split /\n$SUB_SEP\n/;

Another way (solution 2) would be to change the sequence '-----' to something more "exotic" like '-=*-=*-=*'. This can be done by changing lines 3038 of MT/App/CMS.pm to

my $SUB_SEP = ('-=*' x 3);

and changing lines 2970, 2973, 2976, 2979, 2982, 2991 and 3001 from '-----' to '-=*-=*-=*'

The cleanest way this issue can be handled is to use XML files to import and export data (thanks to Jacques Distler for pointing this out). I wonder why Ben and Mena did not think about (or if they did think about it, discard) the XML idea?