Changeset 31126

Show
Ignore:
Timestamp:
18.11.2016 14:28:11 (3 years ago)
Author:
kjdon
Message:

to allow metadata values to contain & and ; when doing online editing, we need to doubly encode them. unencoded & will cause an error later when doing unXMlEncode on the string, and ; is used as a delimiter by perl CGI, so the value gets split at that point if it is not encoded

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/documentmaker_scripts_util.js

    r31122 r31126  
    77var HALTED = 12; 
    88 
     9function encodeDelimiters(meta_value) { 
     10 
     11    var new_value = meta_value.replace(/;/g, "%253B"); 
     12    return new_value.replace(/&/g, "%2526"); 
     13}     
    914 
    1015function getElementsByClassName(cl, parent)  
     
    364369        } 
    365370        if (change.type == "delete") { 
    366           gs.functions.removeArchivesMetadata(collection, gs.xsltParams.site_name, change.docID, change.name, null, change.value, function(){callbackFunction();}); 
     371            gs.functions.removeArchivesMetadata(collection, gs.xsltParams.site_name, change.docID, change.name, null, encodeDelimiters(change.value), function(){callbackFunction();}); 
    367372        } else { 
    368373          if(change.orig) 
    369374            { 
    370               gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, null, change.value, change.orig, "override", function(){callbackFunction();}); 
     375            gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, null, encodeDelimiters(change.value), encodeDelimiters(change.orig), "override", function(){callbackFunction();}); 
    371376            } 
    372377          else 
    373378            { 
    374               gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, null, change.value, null, "accumulate", function(){callbackFunction();}); 
     379            gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, null, encodeDelimiters(change.value), null, "accumulate", function(){callbackFunction();}); 
    375380            } 
    376381        }