vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Issues with /r/n/r/n when displaying escaped data (https://vborg.vbsupport.ru/showthread.php?t=154998)

Antivirus 08-12-2007 01:15 AM

Issues with /r/n/r/n when displaying escaped data
 
I'm having an issue where I need to display data for user to edit in a <textarea> field. For instance, user enters following data:
Quote:

Posted the banner on my myspace profile. Also posted their video on my blog, etc...

Oh yes i did.

That's what I am talking about. "oh yeah" i said
And i use the input cleaner on it as TYPE_NOHTML and escape it using $db->escape_string() which stores it in the db like this:
Quote:

Posted the banner on my myspace profile. Also posted their video on my blog, etc... \r\n\r\nOh yes i did.\r\n\r\nThat\'s what I am talking about. &quot;oh yeah&quot; i said

I'm actually escaping the user input with this before sending it to a custom datamanager which I have attached. That's where the save takes place.

PHP Code:

// Escape stuff to prevent Sql Injection from nasty people
$pagetext    $db->escape_string($pagetext);
$url        $db->escape_string($url);

// init fbpost datamanager class
$fbpostdata =& datamanager_init('scFbpost'$vbulletinERRTYPE_STANDARD);
// set existing data
$fbpostdata->set_existing($fbpost);
// set new data
$fbpostdata->setr('pagetext',    $pagetext);
$fbpostdata->setr('url'$url);
$fbpostdata->pre_save();
$fbpostdata->save(); 


Then to diplay the data I loop through the SQL result as follows:
PHP Code:

while ($fdbkdetail $db->fetch_array($feedbackdetail_result)) 
{
    
// Create the feedback post id
    
$fbpostid    $vbphrase['feedback'] . " Post id:" $fdbkdetail['postid'];
    
    
// Parse the listbit template
    
eval('$feedbackbits .= "' fetch_template('sc_myteams_feedback_bit') . '";');


Anu idea how to get the data to display in the <textarea> field as entered, and without all the /r/n stuff?

Thanks :)

Adrian Schneider 08-12-2007 01:54 AM

You don't have to escape it when using the datamanager, since they will call it for you. Only use it when sticking unsafe strings into queries.

Antivirus 08-12-2007 02:13 AM

ah , i see. So the datamanager class already takes care of escaping, etc... I wasn't aware of that. I searched throughout class_dm.php for $db->escape_string but couldn't find it so i didn't think that was being handled.

Thanks, they should put you on staff here. ;)

Adrian Schneider 08-12-2007 02:37 AM

It would be $this->dbobject->escape_string there.

Antivirus 08-12-2007 03:24 AM

AH YES THAT'S RIGHT!, ok i'm learning, lol


All times are GMT. The time now is 11:08 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01506 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete