opensource-socialnetwork / opensource-socialnetwork

Open Source Social Network (OSSN) is a social networking software written in PHP. It allows you to make a social networking website and helps your members build social relationships, with people who share similar professional or personal interests. It is available in 17 international languages.
https://www.opensource-socialnetwork.org
Other
1.07k stars 506 forks source link

Restore new lines in post edit form #1499

Closed lianglee closed 4 years ago

lianglee commented 5 years ago

ossn_restore_new_lines

<?php
/**
 * Open Source Social Network
 *
 * @package   (softlab24.com).ossn
 * @author    OSSN Core Team <info@softlab24.com>
 * @copyright (C) SOFTLAB24 LIMITED
 * @license   Open Source Social Network License (OSSN LICENSE)  http://www.opensource-socialnetwork.org/licence
 * @link      https://www.opensource-socialnetwork.org/
 */
 $description = json_decode(html_entity_decode($params['post']->description));
 $description = $description->post;
 ?>
 <div>
    <textarea id="post-edit" name="post"><?php echo ossn_restore_new_lines($description);?></textarea>
    <input type="hidden"  name="guid" value="<?php echo $params['post']->guid;?>" />
    <input type="submit" class="hidden" id="ossn-post-edit-save" />
 </div>
githubertus commented 5 years ago

No idea for what this was meant? Just tried:

  1. new post like l1 l2 l3 clicked 'Post' - and all linebreaks appeared correctly on newsfeed

  2. clicked 'Edit' - and all linebreaks appeared correctly in editor box

  3. added a new line (l4) and clicked 'Save' newfeed looks correctly now like l1 l2 l3 l4

Can't see anything going wrong ...

lianglee commented 5 years ago

Hi, sorry for not mentioning and creating it with less information. Actually there is no bug in OSSN, but i was testing this with old database. That have \r\n saved into the posts (object) When i tried to edit the post it still shows \r\n because that was very old post and old database.