Mumble URL with Server Password

Mumble about Mumble

Re: Mumble URL with Server Password

Postby kissaki » Sun Oct 12, 2014 5:20 pm

http://stackoverflow.com/a/130323

In this case, you could use preg_match
http://php.net/manual/en/function.preg-match.php
Something like
Code: Select all
if (preg_match('[-=\\w\\[\\]\\{\\}\\(\\)\\@\\|\\.]+', $name) == 1) {
  $url = sprintf("mumble://$name:serverpassword@server");
  echo '<a href="' . $url . '">connect</a>';
} else {
  echo 'Username not allowed. Please try reducing special characters you used.';
}
MumPI: Your Mumble Web Interface in PHP
User avatar
kissaki
Team member
Team member
 
Posts: 1289
Joined: Sat Jan 09, 2010 12:15 pm

Re: Mumble URL with Server Password

Postby fwaggle » Mon Oct 13, 2014 6:57 am

I would do something like:

kissaki wrote:
Code: Select all
if (preg_match('[-=\\w\\[\\]\\{\\}\\(\\)\\@\\|\\.]+', $name) == 1) {
  $url = sprintf("mumble://$name:serverpassword@server");
  echo '<a href="' . htmlentities($url) . '">connect</a>';
} else {
  echo 'Username not allowed. Please try reducing special characters you used.';
}


But I'm a pretty paranoid guy. :D
Full disclosure: I used to run a commercial Mumble host, and my opinions do not reflect the opinions of the Mumble project.
Avatar is stolen from here
User avatar
fwaggle
Team member
Team member
 
Posts: 217
Joined: Tue Oct 06, 2009 10:40 pm
Location: Australia

Re: Mumble URL with Server Password

Postby Lindee » Mon Oct 13, 2014 2:39 pm

fwaggle wrote:I would do something like:

kissaki wrote:
Code: Select all
if (preg_match('[-=\\w\\[\\]\\{\\}\\(\\)\\@\\|\\.]+', $name) == 1) {
  $url = sprintf("mumble://$name:serverpassword@server");
  echo '<a href="' . htmlentities($url) . '">connect</a>';
} else {
  echo 'Username not allowed. Please try reducing special characters you used.';
}


But I'm a pretty paranoid guy. :D


So, I tried this code...No matter what I type in the field, i get the username not allowed message...do i need to add A-Z on the preg_match?
Lindee
 
Posts: 83
Joined: Fri Sep 19, 2014 12:20 pm

Re: Mumble URL with Server Password

Postby kissaki » Mon Oct 13, 2014 4:18 pm

Remove the double escaping. \ instead of \\.
MumPI: Your Mumble Web Interface in PHP
User avatar
kissaki
Team member
Team member
 
Posts: 1289
Joined: Sat Jan 09, 2010 12:15 pm

Re: Mumble URL with Server Password

Postby Lindee » Mon Oct 13, 2014 4:42 pm

This is what i currently have:

Code: Select all
if (preg_match('[ \-=\w\#\[\]\{\}\(\)\'\!\:\@\\\|]+', $name) == 1) {
  $url = sprintf("mumble://$name:password@server:port/Group Channels/channel?title=Aisthesis&version=1.2.0");
  echo '<a href="' . htmlentities($url) . '">connect</a>';
} else {
  echo 'Username not allowed. Please try reducing special characters you used.';
}
Lindee
 
Posts: 83
Joined: Fri Sep 19, 2014 12:20 pm

Re: Mumble URL with Server Password

Postby fwaggle » Tue Oct 14, 2014 7:23 am

Try this:

Code: Select all
if (preg_match('/^[ \-=\w\#\[\]\{\}\(\)\'\!\:\@\\\|]+$/'$name) == 1) {
 


It worked for me. For preg_match(), php seems to expect perl-style regular expressions which require the forward slashes around it. Also, in my testing, not having the caret and dollar sign (for start and end of string) means that any username that has at least one of the legal characters will be allowed, so I included those too.
Full disclosure: I used to run a commercial Mumble host, and my opinions do not reflect the opinions of the Mumble project.
Avatar is stolen from here
User avatar
fwaggle
Team member
Team member
 
Posts: 217
Joined: Tue Oct 06, 2009 10:40 pm
Location: Australia

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests