[opw-web] Fix mangling of line breaks when editing descriptions



commit e4f47471c513b935033fe56ed4a94629afefcaed
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Wed Mar 19 11:37:09 2014 -0400

    Fix mangling of line breaks when editing descriptions
    
    Don't substitute new lines with <br /> when filling in the existing
    content for the description text box.

 modules/mod_view_projects.php |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/modules/mod_view_projects.php b/modules/mod_view_projects.php
index ca1a224..1cca451 100644
--- a/modules/mod_view_projects.php
+++ b/modules/mod_view_projects.php
@@ -320,12 +320,16 @@ if ($action == 'editor')
     $cancel_url = !empty($return_url) ? "?q=view_projects&amp;prg={$program_id}&amp;p={$project_id}"
                                       : "?q=program_home&amp;prg={$program_id}";
 
+    $escaped_description = htmlspecialchars($description);
+    $escaped_description = preg_replace('/\n/', '&#10;', $escaped_description);
+    $escaped_description = preg_replace('/\r/', '&#13;', $escaped_description);
+
     // Assign skin data
     $skin->assign(array(
         'editor_title'          => $page_title,
         'program_id'            => $program_id,
         'project_title'         => htmlspecialchars($title),
-        'project_description'   => nl2br(htmlspecialchars($description)),
+        'project_description'   => $escaped_description,
         'new_mentor'            => htmlspecialchars($new_mentor),
         'organization_select'   => build_organization_select($program_id, $organization_id,
                                                              false,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]