Skip to content

Conversation

@trhermans
Copy link
Contributor

Added a case for embedding a playlist using youtube.

Added a case for embedding a playlist using youtube.
syntax.php Outdated
foreach($paramm as $key => $value) {
switch($key) {
case 'list':
$urlparam[] = $key . '=' . $paramm[$key];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the set parameter is later printed without any further sanitation, it needs to be sanitized here. The way it is implemented currently would open an XSS vulnerability

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also $param[$key] is the same as $value, so why not use that - it's a bit cleaner.

@trhermans
Copy link
Contributor Author

I corrected to use the $value variable as recommended, I had used the other format to match the existing code.

I additionally added a check that the playlist id is a string, not sure if further sanitization is necessary, as I typically do not work on web programming. Happy to work out a more complicated check, if you could be more specific on what is necessary.

@splitbrain
Copy link
Owner

The value will be a string for sure because it comes from the syntax. The problem arises when it contains HTML tags. I don't know what format youtube playlist identifiers have, but this format should be checked (probably using a regexp).

@trhermans
Copy link
Contributor Author

Okay, I've created a regex match to ensure it has the format ID used by youtube playlists of alphanumeric strings with underscores and dashes.

syntax.php Outdated
foreach($paramm as $key => $value) {
switch($key) {
case 'list':
if(preg_match('/(\w|-)+/',$value)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the regexp isn't anchored it would still match anything as long as it contains at least one letter. try /^[-\w]+$/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected

@splitbrain splitbrain merged commit da38eb7 into splitbrain:master Mar 7, 2017
@splitbrain
Copy link
Owner

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants