Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-09-2013, 01:10 PM
Th3Dan Th3Dan is offline
 
Join Date: Dec 2013
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Datamanger PM Recipient with HTMLl chars

Hello,

i made a plugin to notify users automated via PN

PHP Code:
$pmdm datamanager_init('PM'$vbulletinERRTYPE_ARRAY);
    
$pmdm->set('fromuserid'$vbulletin->userinfo['userid']);
    
$pmdm->set('fromusername'$vbulletin->userinfo['username']);
    
$pmdm->set('title''Test']);
    
$pmdm->set('message'$message);
    
$pmdm->set_recipients($tousernamenull);
    
$pmdm->set('dateline'TIMENOW);
    
$pmdm->set_info('savecopy'1);
    
$pmdm->set_info('receipt'0);
    
$pmdm->pre_save(); 
$tousername is the name of the target user for the pn. I've an user with a '<' char in his username. This failed and i get an error in the $pmdm->errors array that the user can't be found. The '<' was masked as html so '&lt'. I took a look at the source and found the function in includes/class_dm_pm.php:

PHP Code:
function set_recipients($recipientlist, &$permissions$type 'bcc')
    {
        global 
$vbphrase;
        
$names = array();      // names in the recipient list
        
$users = array();      // users from the recipient list found in the user table
        
$notfound = array();   // names from the recipient list NOT found in the user table
        
$recipients = array(); // users to whom the message WILL be sent
        
$errors = array();

        
$recipientlist trim($recipientlist);

        
$this->info['permissions'] =& $permissions;

        if (!empty(
$this->info['is_automated']))
        {
            
$this->overridequota true;
        }

        
// pmboxfull needs $fromusername defined
        
if (($fromusername $this->fetch_field('fromusername')) === null)
        {
            
trigger_error('Set fromusername before calling set_recipients()'E_USER_ERROR);
        }

        if ((
$fromuserid $this->fetch_field('fromuserid')) === null)
        {
            
trigger_error('Set fromuserid before calling set_recipients()'E_USER_ERROR);
        }
        
$fromuser fetch_userinfo($fromuserid);

        
// check for valid recipient string
        
if ($recipientlist == '')
        {
            return 
false;
        }

        
// split multiple recipients into an array
        
if (preg_match('/(?<!&#[0-9]{3}|&#[0-9]{4}|&#[0-9]{5});/'$recipientlist)) // multiple recipients attempted
        
{
            
$recipientlist preg_split('/(?<!&#[0-9]{3}|&#[0-9]{4}|&#[0-9]{5});/'$recipientlist, -1PREG_SPLIT_NO_EMPTY);
            foreach (
$recipientlist AS $recipient)
            {
                
$recipient trim($recipient);
                if (
$recipient != '')
                {
                    
$names[] = htmlspecialchars_uni($recipient);
                }
            }
        } 
I found the info that htmlspecialchars_uni() is used to display data in clean form and to prevent xss. So I think this function is masking the '<' because it's the beginning of any HTML tag and as &lt it will be displayed and not interpreted as HTML. But what can i do to avoid this? Is there another way so that pns to users with a '<' in the username can be send? I think there must be a way to avoid this. PNs in vBulletin are possible to users with a '<' in the name and I think vBulletin also uses this class.
Reply With Quote
  #2  
Old 12-12-2013, 10:18 PM
Th3Dan Th3Dan is offline
 
Join Date: Dec 2013
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Push
Reply With Quote
  #3  
Old 12-13-2013, 01:00 PM
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Oct 2005
Location: Czech
Posts: 345
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$this->db->escape_string($recipient);
Reply With Quote
  #4  
Old 12-16-2013, 10:02 PM
Th3Dan Th3Dan is offline
 
Join Date: Dec 2013
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, i don't want to modify the vB source, that's the problem. The first code is my, the second one is from vBulletin (includes/class_dm_pm.php). I want to fix this without modify the core.
Reply With Quote
  #5  
Old 12-16-2013, 10:46 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't understand why that's happening, but you might try using unhtmlspecialchars($tousername).
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:54 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.03864 seconds
  • Memory Usage 2,223KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete