aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-13 16:19:47 -0700
committerzotlabs <mike@macgirvin.com>2017-03-13 16:19:47 -0700
commit58aa0f3e1a52a0c20016a4330100231ad505e6e4 (patch)
treea599768b88ac95a8c8bc395371b249dd5ab518d4 /include/text.php
parent02b390d7b867750aa466f912a8e1024d35ebf4e8 (diff)
downloadvolse-hubzilla-58aa0f3e1a52a0c20016a4330100231ad505e6e4.tar.gz
volse-hubzilla-58aa0f3e1a52a0c20016a4330100231ad505e6e4.tar.bz2
volse-hubzilla-58aa0f3e1a52a0c20016a4330100231ad505e6e4.zip
code_allowed is a real mess. Start the cleanup by remving the account level code allow and limiting to specific channels only. This reduces the possibility of cross channel security issues coming into play. Then provide a single function for checking the code permission. This is only partially done as we often need to check against the observer or logged in channel as well as the resource owner to ensure that this only returns true for local channels which also own the requested resource.
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php26
1 files changed, 4 insertions, 22 deletions
diff --git a/include/text.php b/include/text.php
index fe3206b32..6715eca22 100644
--- a/include/text.php
+++ b/include/text.php
@@ -104,15 +104,11 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') {
return $s;
}
- $r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1",
+ $r = q("select channel_pageflags from channel where channel_id = %d limit 1",
intval($channel_id)
);
- if($r) {
- if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
- if(local_channel() && (get_account_id() == $r[0]['account_id'])) {
- return $s;
- }
- }
+ if(($r) && (local_channel() == $channel_id) && ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
+ return $s;
}
if($type === 'text/html')
@@ -1795,23 +1791,9 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
);
- if(App::$is_sys) {
+ if((App::$is_sys) || (channel_codeallowed($channel_id) && $channel_id == local_channel())){
$x[] = 'application/x-php';
}
- else {
- $r = q("select account_id, account_roles, channel_pageflags from account left join channel on account_id = channel_account_id where
- channel_id = %d limit 1",
- intval($channel_id)
- );
-
- if($r) {
- if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
- if(local_channel() && get_account_id() == $r[0]['account_id']) {
- $x[] = 'application/x-php';
- }
- }
- }
- }
foreach($x as $y) {
$selected = (($y == $current) ? ' selected="selected" ' : '');