Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
fcf34c3a
Commit
fcf34c3a
authored
16 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#311946
:
SA-2008
-060 (
#318706
): BlogAPI access bypass.
parent
706ea3e5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/blogapi/blogapi.module
+46
-3
46 additions, 3 deletions
modules/blogapi/blogapi.module
with
46 additions
and
3 deletions
modules/blogapi/blogapi.module
+
46
−
3
View file @
fcf34c3a
...
...
@@ -226,6 +226,11 @@ function blogapi_blogger_new_post($appkey, $blogid, $username, $password, $conte
node_invoke_nodeapi
(
$edit
,
'blogapi_new'
);
$valid
=
blogapi_status_error_check
(
$edit
,
$publish
);
if
(
$valid
!==
TRUE
)
{
return
$valid
;
}
node_validate
(
$edit
);
if
(
$errors
=
form_get_errors
())
{
return
blogapi_error
(
implode
(
"
\n
"
,
$errors
));
...
...
@@ -262,7 +267,8 @@ function blogapi_blogger_edit_post($appkey, $postid, $username, $password, $cont
if
(
!
node_access
(
'update'
,
$node
))
{
return
blogapi_error
(
t
(
'You do not have permission to update this post.'
));
}
// Save the original status for validation of permissions.
$original_status
=
$node
->
status
;
$node
->
status
=
$publish
;
// check for bloggerAPI vs. metaWeblogAPI
...
...
@@ -278,6 +284,11 @@ function blogapi_blogger_edit_post($appkey, $postid, $username, $password, $cont
node_invoke_nodeapi
(
$node
,
'blogapi_edit'
);
$valid
=
blogapi_status_error_check
(
$node
,
$original_status
);
if
(
$valid
!==
TRUE
)
{
return
$valid
;
}
node_validate
(
$node
);
if
(
$errors
=
form_get_errors
())
{
return
blogapi_error
(
implode
(
"
\n
"
,
$errors
));
...
...
@@ -310,6 +321,33 @@ function blogapi_blogger_get_post($appkey, $postid, $username, $password) {
return
_blogapi_get_post
(
$node
,
TRUE
);
}
/**
* Check that the user has permission to save the node with the chosen status.
*
* @return
* TRUE if no error, or the blogapi_error().
*/
function
blogapi_status_error_check
(
$node
,
$original_status
)
{
$node
=
(
object
)
$node
;
$node_type_default
=
variable_get
(
'node_options_'
.
$node
->
type
,
array
(
'status'
,
'promote'
));
// If we don't have the 'administer nodes' permission and the status is
// changing or for a new node the status is not the content type's default,
// then return an error.
if
(
!
user_access
(
'administer nodes'
)
&&
((
$node
->
status
!=
$original_status
)
||
(
empty
(
$node
->
nid
)
&&
$node
->
status
!=
in_array
(
'status'
,
$node_type_default
))))
{
if
(
$node
->
status
)
{
return
blogapi_error
(
t
(
'You do not have permission to publish this type of post. Please save it as a draft instead.'
));
}
else
{
return
blogapi_error
(
t
(
'You do not have permission to save this post as a draft. Please publish it instead.'
));
}
}
return
TRUE
;
}
/**
* Blogging API callback. Removes the specified blog node.
*/
...
...
@@ -516,11 +554,16 @@ function blogapi_mt_publish_post($postid, $username, $password) {
return
blogapi_error
(
t
(
'Invalid post.'
));
}
$node
->
status
=
1
;
if
(
!
node_access
(
'update'
,
$node
))
{
// Nothing needs to be done if already published.
if
(
$node
->
status
)
{
return
;
}
if
(
!
node_access
(
'update'
,
$node
)
||
!
user_access
(
'administer nodes'
))
{
return
blogapi_error
(
t
(
'You do not have permission to update this post.'
));
}
$node
->
status
=
1
;
node_save
(
$node
);
return
TRUE
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment