From c93db2cd218d5a1e8ff6e5b243b99e7fcbae36ea Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 9 Mar 2017 14:31:54 -0800 Subject: more cleanup --- include/text.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 9d76f9d78..fe3206b32 100644 --- a/include/text.php +++ b/include/text.php @@ -1183,8 +1183,7 @@ function list_smilies() { ':coffee', ':facepalm', ':like', - ':dislike', - ':hubzilla' + ':dislike' ); $icons = array( @@ -1219,8 +1218,7 @@ function list_smilies() { ':coffee', ':facepalm', ':like', - ':dislike', - ':hubzilla', + ':dislike' ); -- cgit v1.2.3 From 58aa0f3e1a52a0c20016a4330100231ad505e6e4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 13 Mar 2017 16:19:47 -0700 Subject: 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. --- include/text.php | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'include/text.php') 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" ' : ''); -- cgit v1.2.3 From 2c73b457ef0943d46804480a0aa016f64c11edbf Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Mar 2017 17:07:29 -0700 Subject: input filter updates --- include/text.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 6715eca22..500c87ad5 100644 --- a/include/text.php +++ b/include/text.php @@ -3,6 +3,7 @@ * @file include/text.php */ +use \Zotlabs\Lib as Zlib; use \Michelf\MarkdownExtra; require_once("include/bbcode.php"); @@ -89,12 +90,10 @@ function escape_tags($string) { } -function z_input_filter($channel_id,$s,$type = 'text/bbcode') { +function z_input_filter($s,$type = 'text/bbcode',$allow_code = false) { if($type === 'text/bbcode') return escape_tags($s); - if($type === 'text/markdown') - return escape_tags($s); if($type == 'text/plain') return escape_tags($s); if($type == 'application/x-pdl') @@ -104,13 +103,17 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') { return $s; } - $r = q("select channel_pageflags from channel where channel_id = %d limit 1", - intval($channel_id) - ); - if(($r) && (local_channel() == $channel_id) && ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) { + if($allow_code) { + if($type === 'text/markdown') + return htmlspecialchars($s,ENT_QUOTES); return $s; } + if($type === 'text/markdown') { + $x = new Zlib\MarkdownSoap($s); + return $x->clean(); + } + if($type === 'text/html') return purify_html($s); @@ -1636,6 +1639,7 @@ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) { break; case 'text/markdown': + $text = Zlib\MarkdownSoap::unescape($text); $s = MarkdownExtra::defaultTransform($text); break; -- cgit v1.2.3 From bedc39342514a37d311274210f30a4abd14284fa Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Mar 2017 20:11:48 -0700 Subject: begin the process of using the relevant attach directory/path for photo albums instead of an album basename which may not be unique. Created an 'ellipsify()' function to shorten long names and keep the beginning and end intact --- include/text.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 500c87ad5..49b588f13 100644 --- a/include/text.php +++ b/include/text.php @@ -3113,3 +3113,14 @@ function array_escape_tags(&$v,$k) { $v = escape_tags($v); } +function ellipsify($s,$maxlen) { + if($maxlen & 1) + $maxlen --; + if($maxlen < 4) + $maxlen = 4; + + if(mb_strlen($s) < $maxlen) + return $s; + + return mb_substr($s,0,$maxlen / 2) . '...' . mb_substr($s,mb_strlen($s) - ($maxlen / 2)); +} \ No newline at end of file -- cgit v1.2.3 From a92256e1cbd0b6bcaac5711c751479b97b30e00e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 3 Apr 2017 22:13:12 -0700 Subject: legal_webbie() now provides different character rules depending on whether you federate or not. Added some comments in a few places that needed them. --- include/text.php | 67 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 25 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 1b0150706..e02becf31 100644 --- a/include/text.php +++ b/include/text.php @@ -2000,23 +2000,40 @@ function legal_webbie($s) { if(! strlen($s)) return ''; + + // Has to start with a lowercase alphabetic character - not a number. + // This is so we can differentiate between something like channel=123 + // and channel=foo and lookup the first by numeric id and the second + // by nickname. + $x = $s; do { $s = $x; $x = preg_replace('/^([^a-z])(.*?)/',"$2",$s); } while($x != $s); - return preg_replace('/([^a-z0-9\-\_])/','',$x); + // Use the lowest common denominator rules (letters, numbers, and underscore) + // if the site configuration allows federation with other networks + + if(Zlib\System::get_server_role() === 'pro') { + return preg_replace('/([^a-z0-9\-\_\.])/','',$x); + } + else { + return preg_replace('/([^a-z0-9\_])/','',$x); + } } function check_webbie($arr) { + + // These names conflict with the CalDAV server + $taken = [ 'principals', 'addressbooks', 'calendars' ]; + $reservechan = get_config('system','reserved_channels'); - if(strlen($reservechan)) - $taken = explode(',', $reservechan); - else - $taken = array('principals','addressbooks','calendars'); + if(strlen($reservechan)) { + $taken = array_merge($taken,explode(',', $reservechan)); + } $str = ''; if(count($arr)) { @@ -2267,13 +2284,13 @@ function design_tools() { $who = $channel['channel_address']; return replace_macros(get_markup_template('design_tools.tpl'), array( - '$title' => t('Design Tools'), - '$who' => $who, - '$sys' => $sys, + '$title' => t('Design Tools'), + '$who' => $who, + '$sys' => $sys, '$blocks' => t('Blocks'), - '$menus' => t('Menus'), + '$menus' => t('Menus'), '$layout' => t('Layouts'), - '$pages' => t('Pages') + '$pages' => t('Pages') )); } @@ -2294,21 +2311,21 @@ function website_portation_tools() { } return replace_macros(get_markup_template('website_portation_tools.tpl'), array( - '$title' => t('Import'), - '$import_label' => t('Import website...'), - '$import_placeholder' => t('Select folder to import'), - '$file_upload_text' => t('Import from a zipped folder:'), - '$file_import_text' => t('Import from cloud files:'), - '$desc' => t('/cloud/channel/path/to/folder'), - '$hint' => t('Enter path to website files'), - '$select' => t('Select folder'), - '$export_label' => t('Export website...'), - '$file_download_text' => t('Export to a zip file'), - '$filename_desc' => t('website.zip'), - '$filename_hint' => t('Enter a name for the zip file.'), - '$cloud_export_text' => t('Export to cloud files'), - '$cloud_export_desc' => t('/path/to/export/folder'), - '$cloud_export_hint' => t('Enter a path to a cloud files destination.'), + '$title' => t('Import'), + '$import_label' => t('Import website...'), + '$import_placeholder' => t('Select folder to import'), + '$file_upload_text' => t('Import from a zipped folder:'), + '$file_import_text' => t('Import from cloud files:'), + '$desc' => t('/cloud/channel/path/to/folder'), + '$hint' => t('Enter path to website files'), + '$select' => t('Select folder'), + '$export_label' => t('Export website...'), + '$file_download_text' => t('Export to a zip file'), + '$filename_desc' => t('website.zip'), + '$filename_hint' => t('Enter a name for the zip file.'), + '$cloud_export_text' => t('Export to cloud files'), + '$cloud_export_desc' => t('/path/to/export/folder'), + '$cloud_export_hint' => t('Enter a path to a cloud files destination.'), '$cloud_export_select' => t('Specify folder'), )); } -- cgit v1.2.3 From 9fb08fb5022c9eaf6368a9d3ac07bb1dcf856c20 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 5 Apr 2017 19:08:43 -0700 Subject: make legal_webbie() pluggable - * this should not be merged with federated projects unless the federation drivers make use of the hooks. --- include/text.php | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index e02becf31..bbf0b5b98 100644 --- a/include/text.php +++ b/include/text.php @@ -2000,30 +2000,34 @@ function legal_webbie($s) { if(! strlen($s)) return ''; + // WARNING: This regex will not work in a federated environment. + // You will probably want something like + // preg_replace('/([^a-z0-9\_])/','',strtolower($s)); - // Has to start with a lowercase alphabetic character - not a number. - // This is so we can differentiate between something like channel=123 - // and channel=foo and lookup the first by numeric id and the second - // by nickname. + $r = preg_replace('/([^a-z0-9\-\_\.])/','',strtolower($s)); - $x = $s; - do { - $s = $x; - $x = preg_replace('/^([^a-z])(.*?)/',"$2",$s); - } while($x != $s); + $x = [ 'input' => $s, 'output' => $r ]; + call_hooks('legal_webbie',$x); + return $x['output']; - // Use the lowest common denominator rules (letters, numbers, and underscore) - // if the site configuration allows federation with other networks +} + +function legal_webbie_text() { + + // WARNING: This will not work in a federated environment. + + $s = t('a-z, 0-9, -, _, and . only'); + + $x = [ 'text' => $s ]; + call_hooks('legal_webbie_text',$x); + return $x['text']; - if(Zlib\System::get_server_role() === 'pro') { - return preg_replace('/([^a-z0-9\-\_\.])/','',$x); - } - else { - return preg_replace('/([^a-z0-9\_])/','',$x); - } } + + + function check_webbie($arr) { -- cgit v1.2.3 From 397fef519c7929c70636c50015f7a0389062bab5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 18 Apr 2017 21:18:49 -0700 Subject: give the item_obscured flag a new lease on life by using it to designate third party client-side e2ee or binary content which can only be downloaded and not viewed directly on the web (as a side effect this also allows binary files to be submitted as activities/content). The content display is suppressed and replaced with a download button. This is unfinished but harmless to backport while work is in progress unless told otherwise. Future development will take care of the remaining loose ends. --- include/text.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index bbf0b5b98..d276595ae 100644 --- a/include/text.php +++ b/include/text.php @@ -1570,7 +1570,12 @@ function prepare_body(&$item,$attach = false) { } } - $s .= prepare_text($item['body'],$item['mimetype'], false); + if($item['item_obscured']) { + $s .= prepare_binary($item); + } + else { + $s .= prepare_text($item['body'],$item['mimetype'], false); + } $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false); @@ -1633,6 +1638,17 @@ function prepare_body(&$item,$attach = false) { return $prep_arr; } + +function prepare_binary($item) { + return replace_macros(get_markup_template('item_binary.tpl'), [ + '$download' => t('Download binary/encrypted content'), + '$url' => z_root() . '/viewsrc/' . $item['id'] . '/download' + ]); +} + + + + /** * @brief Given a text string, convert from bbcode to html and add smilie icons. * -- cgit v1.2.3 From 94f15e355166f0abd3698414948abff2397a7ad0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 20 Apr 2017 20:19:15 -0700 Subject: The rest of the library and backend changes to support client-side e2ee and deprecate previous uses of item_obscured. --- include/text.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index d276595ae..1a4e2b223 100644 --- a/include/text.php +++ b/include/text.php @@ -1372,20 +1372,7 @@ function link_compare($a, $b) { function unobscure(&$item) { - if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) { - $key = get_config('system','prvkey'); - if($item['title']) - $item['title'] = crypto_unencapsulate(json_decode($item['title'],true),$key); - if($item['body']) - $item['body'] = crypto_unencapsulate(json_decode($item['body'],true),$key); - if(get_config('system','item_cache')) { - q("update item set title = '%s', body = '%s', item_obscured = 0 where id = %d", - dbesc($item['title']), - dbesc($item['body']), - intval($item['id']) - ); - } - } + return; } function unobscure_mail(&$item) { -- cgit v1.2.3 From f1c6fd08c462b663a26cf58cfd81591129057c41 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 23 Apr 2017 20:28:04 -0700 Subject: database upgrade --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 1a4e2b223..d9ee40fa9 100644 --- a/include/text.php +++ b/include/text.php @@ -2930,7 +2930,7 @@ function pdl_selector($uid, $current='') { $sql_extra = item_permissions_sql($uid); - $r = q("select iconfig.*, mid from item_id left join item on iconfig.iid = item.id + $r = q("select iconfig.*, mid from iconfig left join item on iconfig.iid = item.id where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' $sql_extra order by v asc", intval($uid) ); -- cgit v1.2.3 From a342a5f8e062bf3b1d8cfebaaa64214c7dae49cb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 25 Apr 2017 16:36:37 -0700 Subject: smilies - add param to only list default emoticons --- include/text.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index d9ee40fa9..14a60f060 100644 --- a/include/text.php +++ b/include/text.php @@ -1166,7 +1166,7 @@ function get_mood_verbs() { * * @return Returns array with keys 'texts' and 'icons' */ -function list_smilies() { +function list_smilies($default_only = false) { $texts = array( '<3', @@ -1240,10 +1240,15 @@ function list_smilies() { ); $params = array('texts' => $texts, 'icons' => $icons); + + if($default_only) + return $params; + call_hooks('smilie', $params); return $params; } + /** * @brief Replaces text emoticons with graphical images. * -- cgit v1.2.3 From 1de1b58a087afbadb55b7f18b93fb0b502a2de3a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 11 May 2017 19:01:04 -0700 Subject: consolidate email validation checks --- include/text.php | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index dc01f97bd..fb39313a2 100644 --- a/include/text.php +++ b/include/text.php @@ -1042,19 +1042,6 @@ function searchbox($s,$id='search-box',$url='/search',$save = false) { )); } -function valid_email_regex($x){ - if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) - return true; - return false; -} - -function valid_email($x){ - if(get_config('system','disable_email_validation')) - return true; - - return valid_email_regex($x); -} - /** * @brief Replace naked text hyperlink with HTML formatted hyperlink. * -- cgit v1.2.3 From 3a00140797fa0d557db2434402ce20258b4ce570 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 23 May 2017 21:20:40 -0700 Subject: remove php version checks for older ( < 5.4) code incompatibilities --- include/text.php | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index b17564b9f..2e77dca84 100644 --- a/include/text.php +++ b/include/text.php @@ -648,12 +648,8 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { $where = ''; - // We require > 5.4 but leave the version check so that install issues (including version) can be logged - - if(version_compare(PHP_VERSION, '5.4.0') >= 0) { - $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - $where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': '; - } + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': '; $s = datetime_convert() . ':' . log_priority_str($priority) . ':' . session_id() . ':' . $where . $msg . PHP_EOL; $pluginfo = array('filename' => $logfile, 'loglevel' => $level, 'message' => $s,'priority' => $priority, 'logged' => false); @@ -687,16 +683,14 @@ function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { @file_put_contents(BTLOGGER_DEBUG_FILE, $s, FILE_APPEND); } - if(version_compare(PHP_VERSION, '5.4.0') >= 0) { - $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - if($stack) { - for($x = 1; $x < count($stack); $x ++) { - $s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()'; - logger($s,$level, $priority); + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + if($stack) { + for($x = 1; $x < count($stack); $x ++) { + $s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()'; + logger($s,$level, $priority); - if(file_exists(BTLOGGER_DEBUG_FILE) && is_writable(BTLOGGER_DEBUG_FILE)) { - @file_put_contents(BTLOGGER_DEBUG_FILE, $s . PHP_EOL, FILE_APPEND); - } + if(file_exists(BTLOGGER_DEBUG_FILE) && is_writable(BTLOGGER_DEBUG_FILE)) { + @file_put_contents(BTLOGGER_DEBUG_FILE, $s . PHP_EOL, FILE_APPEND); } } } @@ -751,10 +745,10 @@ function dlogger($msg, $level = 0) { return; $where = ''; - if(version_compare(PHP_VERSION, '5.4.0') >= 0) { - $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - $where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': '; - } + + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': '; + @file_put_contents($logfile, datetime_convert() . ':' . session_id() . ' ' . $where . $msg . PHP_EOL, FILE_APPEND); } -- cgit v1.2.3 From b15a5f03e61eeef2086d87f497464b00ada3798e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 28 May 2017 19:17:46 -0700 Subject: work through the diaspora_v2 outgoing status posts --- include/text.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 2e77dca84..0666a5e0d 100644 --- a/include/text.php +++ b/include/text.php @@ -3049,7 +3049,8 @@ function array2XML($obj, $array) { if(is_array($value)) { $node = $obj->addChild($key); array2XML($node, $value); - } else { + } + else { $obj->addChild($key, htmlspecialchars($value)); } } -- cgit v1.2.3 From bfad624528499e27125fae18799940319fc32c6d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 May 2017 18:36:19 -0700 Subject: re-arrange a few functions --- include/text.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 0666a5e0d..1a4cb7ced 100644 --- a/include/text.php +++ b/include/text.php @@ -3082,6 +3082,14 @@ function create_table_from_array($table, $arr) { return $r; } +function share_shield($m) { + return str_replace($m[1],'!=+=+=!' . base64url_encode($m[1]) . '=+!=+!=',$m[0]); +} + +function share_unshield($m) { + $x = str_replace(array('!=+=+=!','=+!=+!='),array('',''),$m[1]); + return str_replace($m[1], base64url_decode($x), $m[0]); +} function cleanup_bbcode($body) { -- cgit v1.2.3 From dfc0d4cf59a9de98bc088c80e75877d9fc9fcab9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 May 2017 19:50:41 -0700 Subject: move code syntax highlighting to plugin --- include/text.php | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 1a4cb7ced..c791b50ee 100644 --- a/include/text.php +++ b/include/text.php @@ -2985,40 +2985,13 @@ function text_highlight($s, $lang) { $s = jindent($s); } - if(! strpos('Text_Highlighter', get_include_path())) { - set_include_path(get_include_path() . PATH_SEPARATOR . 'library/Text_Highlighter'); - } - require_once('library/Text_Highlighter/Text/Highlighter.php'); - require_once('library/Text_Highlighter/Text/Highlighter/Renderer/Html.php'); - $options = array( - 'numbers' => HL_NUMBERS_LI, - 'tabsize' => 4, - ); - $tag_added = false; - $s = trim(html_entity_decode($s, ENT_COMPAT)); - $s = str_replace(" ", "\t", $s); - - // The highlighter library insists on an opening php tag for php code blocks. If - // it isn't present, nothing is highlighted. So we're going to see if it's present. - // If not, we'll add it, and then quietly remove it after we get the processed output back. - - if($lang === 'php') { - if(strpos('setRenderer($renderer); - $o = $hl->highlight($s); - $o = str_replace([" ", "\n"], ["    ", ''], $o); + $arr = [ 'text' => $s, 'language' => $lang, 'success' => false ]; + call_hooks('text_highlight',$arr); - if($tag_added) { - $b = substr($o, 0, strpos($o, '
  • ')); - $e = substr($o, strpos($o, '
  • ')); - $o = $b . $e; - } + if($arr['success']) + $o = $arr['text']; + else + $o = $s; return('' . $o . ''); } -- cgit v1.2.3 From fce68f1a39c73246ad449aee1bf7a4b9aba9837f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Jun 2017 18:29:08 -0700 Subject: add rel=noopener to all external target _blank links --- include/text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index c791b50ee..5af4f1b67 100644 --- a/include/text.php +++ b/include/text.php @@ -1531,13 +1531,13 @@ function prepare_body(&$item,$attach = false) { // if original photo width is <= 640px prepend it to item body if($object['link'][0]['width'] && $object['link'][0]['width'] <= 640) { - $s .= '
    ' . $s; + $s .= '
    ' . $s; } // if original photo width is > 640px make it a cover photo if($object['link'][0]['width'] && $object['link'][0]['width'] > 640) { $scale = ((($object['link'][1]['width'] == 1024) || ($object['link'][1]['height'] == 1024)) ? 1 : 0); - $photo = ''; + $photo = ''; } } -- cgit v1.2.3