Author: peter
Date: Mon Sep 14 17:27:37 2009
New Revision: 3293

Log:
switch to using 'htmlspecialchars' to escape XML reserved entities in the MODS 
and DC export templates. Using 'htmlentities' tries to mistakenly escape UTF-8 
characters

Modified:
   
trunk/apps/qubit/modules/informationobject/templates/_dublinCoreSimple.xml.php
   
trunk/apps/qubit/modules/informationobject/templates/exportModsSuccess.xml.php

Modified: 
trunk/apps/qubit/modules/informationobject/templates/_dublinCoreSimple.xml.php
==============================================================================
--- 
trunk/apps/qubit/modules/informationobject/templates/_dublinCoreSimple.xml.php  
    Mon Sep 14 17:05:37 2009        (r3292)
+++ 
trunk/apps/qubit/modules/informationobject/templates/_dublinCoreSimple.xml.php  
    Mon Sep 14 17:27:37 2009        (r3293)
@@ -1,60 +1,60 @@
-<dc:title><?php echo htmlentities($informationObject->getTitle()) ?></dc:title>
+<dc:title><?php echo htmlspecialchars($informationObject->getTitle()) 
?></dc:title>
 <?php foreach ($informationObject->getCreators() as $creator): ?>
-<dc:creator><?php echo htmlentities($creator) ?></dc:creator>
+<dc:creator><?php echo htmlspecialchars($creator) ?></dc:creator>
 <?php endforeach; ?>
 <?php if (count($dcSubjects = QubitDc::getSubjects($informationObject)) > 0): 
?>
   <?php foreach ($dcSubjects as $dcSubject): ?>
-<dc:subject><?php echo htmlentities($dcSubject) ?></dc:subject>
+<dc:subject><?php echo htmlspecialchars($dcSubject) ?></dc:subject>
   <?php endforeach; ?>
 <?php endif; ?>
 <?php if ($informationObject->getScopeAndContent()): ?>
-<dc:description><?php echo 
htmlentities($informationObject->getScopeAndContent()) ?></dc:description>
+<dc:description><?php echo 
htmlspecialchars(nl2br($informationObject->getScopeAndContent())) 
?></dc:description>
 <?php endif; ?>
 <?php foreach ($informationObject->getPublishers() as $publisher): ?>
-<dc:publisher><?php echo htmlentities($publisher) ?></dc:publisher>
+<dc:publisher><?php echo htmlspecialchars($publisher) ?></dc:publisher>
 <?php endforeach; ?>
 <?php foreach ($informationObject->getContributors() as $contributor): ?>
-<dc:contributor><?php echo htmlentities($contributor) ?></dc:contributor>
+<dc:contributor><?php echo htmlspecialchars($contributor) ?></dc:contributor>
 <?php endforeach; ?>
 <?php foreach (QubitDc::getDates($informationObject) as $dcDate): ?>
-<dc:date><?php echo htmlentities($dcDate) ?></dc:date>
+<dc:date><?php echo htmlspecialchars($dcDate) ?></dc:date>
 <?php endforeach; ?>
 <?php if (count($dcTypes = QubitDc::getTypes($informationObject)) > 0): ?>
   <?php foreach ($dcTypes as $dcType): ?>
-<dc:type><?php echo htmlentities($dcType) ?></dc:type>
+<dc:type><?php echo htmlspecialchars($dcType) ?></dc:type>
   <?php endforeach; ?>
 <?php endif; ?>
 <?php if (count($dcFormats = QubitDc::getFormats($informationObject)) > 0): ?>
   <?php foreach ($dcFormats as $dcFormat): ?>
-<dc:format><?php echo htmlentities($dcFormat) ?></dc:format>
+<dc:format><?php echo htmlspecialchars($dcFormat) ?></dc:format>
   <?php endforeach; ?>
 <?php endif; ?>
 <?php if ($informationObject->getIdentifier()): ?>
-<dc:identifier><?php echo 
htmlentities(QubitDc::getIdentifier($informationObject)) ?></dc:identifier>
+<dc:identifier><?php echo 
htmlspecialchars(QubitDc::getIdentifier($informationObject)) ?></dc:identifier>
 <?php endif; ?>
 <?php if ($source = $informationObject->getLocationOfOriginals()): ?>
-<dc:source><?php echo htmlentities($source) ?></dc:source>
+<dc:source><?php echo htmlspecialchars(nl2br($source)) ?></dc:source>
 <?php endif; ?>
 <?php if (count($languages = $informationObject->getProperties($name = 
'information_object_language')) > 0): ?>
   <?php foreach ($languages as $languageCode): ?>
-<dc:language><?php echo htmlentities($languageCode->getValue()) 
?></dc:language>
+<dc:language><?php echo htmlspecialchars($languageCode->getValue()) 
?></dc:language>
   <?php endforeach; ?>
 <?php endif; ?>
 <?php if ($dcRelation['text'] !== ''): ?>
-<dc:relation><?php echo htmlentities($dcRelation['text']) ?></dc:relation>
+<dc:relation><?php echo htmlspecialchars($dcRelation['text']) ?></dc:relation>
 <?php endif; ?>
 <?php if ($dcRelation['identifier']): ?>
-<dc:relation><?php echo htmlentities($dcRelation['identifier']) 
?></dc:relation>
+<dc:relation><?php echo htmlspecialchars($dcRelation['identifier']) 
?></dc:relation>
 <?php endif; ?>
 <?php foreach (QubitDc::getCoverage($informationObject, array('temporal' => 
true)) as $coverageTemporal): ?>
-<dc:coverage><?php echo htmlentities($coverageTemporal) ?></dc:coverage>
+<dc:coverage><?php echo htmlspecialchars($coverageTemporal) ?></dc:coverage>
 <?php endforeach; ?>
 <?php foreach (QubitDc::getCoverage($informationObject, array('spatial' => 
true)) as $coverageSpatial): ?>
-<dc:coverage><?php echo htmlentities($coverageSpatial) ?></dc:coverage>
+<dc:coverage><?php echo htmlspecialchars($coverageSpatial) ?></dc:coverage>
 <?php endforeach; ?>
 <?php if ($accessConditions = $informationObject->getAccessConditions()): ?>
-<dc:rights><?php echo htmlentities($accessConditions) ?></dc:rights>
+<dc:rights><?php echo htmlspecialchars(nl2br($accessConditions)) ?></dc:rights>
 <?php endif; ?>
 <?php if ($reproductionConditions = 
$informationObject->getReproductionConditions()): ?>
-<dc:rights><?php echo htmlentities($reproductionConditions) ?></dc:rights>
+<dc:rights><?php echo htmlspecialchars(nl2br($reproductionConditions)) 
?></dc:rights>
 <?php endif; ?>

Modified: 
trunk/apps/qubit/modules/informationobject/templates/exportModsSuccess.xml.php
==============================================================================
--- 
trunk/apps/qubit/modules/informationobject/templates/exportModsSuccess.xml.php  
    Mon Sep 14 17:05:37 2009        (r3292)
+++ 
trunk/apps/qubit/modules/informationobject/templates/exportModsSuccess.xml.php  
    Mon Sep 14 17:27:37 2009        (r3293)
@@ -6,16 +6,16 @@
     xsi:schemaLocation="http://www.loc.gov/standards/mods/v3/mods-3-3.xsd";
     version="3.3">
 
-<titleInfo><title><?php echo htmlentities($informationObject->getTitle()) 
?></title></titleInfo>
+<titleInfo><title><?php echo htmlspecialchars($informationObject->getTitle()) 
?></title></titleInfo>
 <?php if (count($modsNames = QubitMods::getNames($informationObject)) > 0): ?>
   <?php foreach ($modsNames as $modsName): ?>
 <name type="<?php echo $modsName->getActor()->getEntityType()?>">
-  <namePart><?php echo $modsName->getActor() ?></namePart>
+  <namePart><?php echo htmlspecialchars($modsName->getActor()) ?></namePart>
   <role><?php echo $modsName->getType()->getRole() ?></role>
 </name><?php endforeach; ?><?php endif; ?>
 <?php if (count($modsTypes = QubitMods::getTypes($informationObject)) > 0): ?>
   <?php foreach ($modsTypes as $modsType): ?>
-<typeOfResource><?php echo $modsType->getTerm() ?></typeOfResource><?php 
endforeach; ?><?php endif; ?>
+<typeOfResource><?php echo htmlspecialchars($modsType->getTerm()) 
?></typeOfResource><?php endforeach; ?><?php endif; ?>
 <?php if (count($dates = $informationObject->getDates()) > 0) : ?>
 <originInfo><?php foreach ($dates as $date): ?><?php if ($place = 
$date->getPlace()): ?>
 <place><?php echo $place ?></place><?php endif; ?>
@@ -33,21 +33,21 @@
 <physicalDescription><internetMediaType><?php echo 
$digitalObject->getMimeType() ?></internetMediaType></physicalDescription><?php 
endif; ?><?php endif; ?>
 <?php if (count($subjectAccessPoints = 
$informationObject->getSubjectAccessPoints()) > 0) : ?>
   <?php foreach ($subjectAccessPoints as $subject): ?>
-<subject><?php echo $subject->getTerm() ?></subject><?php endforeach; ?><?php 
endif; ?>
+<subject><?php echo htmlspecialchars($subject->getTerm()) ?></subject><?php 
endforeach; ?><?php endif; ?>
 <?php if ($informationObject->getIdentifier()): ?>
-<identifier><?php echo 
htmlentities(QubitDc::getIdentifier($informationObject)) ?></identifier><?php 
endif; ?>
+<identifier><?php echo 
htmlspecialchars(QubitDc::getIdentifier($informationObject)) 
?></identifier><?php endif; ?>
 <?php if ((QubitMODS::getDigitalObject($informationObject)) || 
($informationObject->getRepository())): ?>
 <location><?php if ($digitalObject = 
QubitMODS::getDigitalObject($informationObject)): ?><url usage="primary 
display">http://<?php echo 
$sf_request->getHost().$sf_request->getRelativeUrlRoot().$digitalObject->getFullPath()
 ?></url><?php endif; ?>
   <?php if ($repository = $informationObject->getRepository()): ?>
     <?php if ($repository->getIdentifier()): ?>
-<physicalLocation><?php echo $repository->getIdentifier() 
?></physicalLocation><?php endif; ?><?php if ($repository->__toString()): ?>    
  <physicalLocation><?php echo $repository->__toString() 
?></physicalLocation><?php endif; ?>
+<physicalLocation><?php echo $repository->getIdentifier() 
?></physicalLocation><?php endif; ?><?php if ($repository->__toString()): ?>    
  <physicalLocation><?php echo htmlspecialchars($repository->__toString()) 
?></physicalLocation><?php endif; ?>
 <?php if ($contactInformation = $repository->getPrimaryContact()): ?>
 <physicalLocation><?php echo $contactInformation->getCity() ?><?php if 
($contactInformation->getCity()): ?><?php echo ', '?><?php endif; ?><?php echo 
$contactInformation->getRegion() ?><?php if ($contactInformation->getRegion() 
&& $contactInformation->getCountryCode()): ?><?php echo ', ' ?><?php endif; 
?><?php echo format_country($contactInformation->getCountryCode()) 
?></physicalLocation><?php endif; ?><?php endif; ?>
 </location><?php endif; ?>
 <?php if (count($children = $informationObject->getChildren()) > 0): ?>
   <?php foreach ($children as $relatedItem): ?>
-<relatedItem type="constituent" ID="<?php echo $relatedItem->getIdentifier() 
?>"><?php echo QubitMods::getLabel($relatedItem); ?></relatedItem> <?php 
endforeach; ?><?php endif; ?>
-<?php if (strlen($value = 
$informationObject->getAccessConditions(array('cultureFallback' => true))) > 0) 
: ?><accessCondition><?php echo nl2br($value) ?></accessCondition><?php endif; 
?>
+<relatedItem type="constituent" ID="<?php echo $relatedItem->getIdentifier() 
?>"><?php echo htmlspecialchars(QubitMods::getLabel($relatedItem)); 
?></relatedItem> <?php endforeach; ?><?php endif; ?>
+<?php if (strlen($value = 
$informationObject->getAccessConditions(array('cultureFallback' => true))) > 0) 
: ?><accessCondition><?php echo htmlspecialchars(nl2br($value)) 
?></accessCondition><?php endif; ?>
 <recordInfo>
 <recordCreationDate><?php echo $informationObject->getCreatedAt() 
?></recordCreationDate>
 <?php if ($informationObject->getCreatedAt() != 
$informationObject->getUpdatedAt()): ?>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to