Ariadne-CMS /
ariadne
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | |||
| 4 | //include_once($me->store->get_config('code')."modules/mod_debug.php"); |
||
| 5 | |||
| 6 | class pinp_page { |
||
| 7 | |||
| 8 | public static function _getBody($page) { |
||
| 9 | return page::getBody($page); |
||
| 10 | } |
||
| 11 | |||
| 12 | public static function _parse($page, $full=false) { |
||
| 13 | return page::parse($page, $full); |
||
| 14 | } |
||
| 15 | |||
| 16 | public static function _isEmpty($page, $full=false) { |
||
|
0 ignored issues
–
show
|
|||
| 17 | return page::isEmpty($page); |
||
| 18 | } |
||
| 19 | |||
| 20 | 12 | public static function _clean($page, $settings=false) { |
|
| 21 | return page::clean($page, $settings); |
||
| 22 | 12 | } |
|
| 23 | |||
| 24 | public static function _compile($page, $language='') { |
||
| 25 | return page::compile($page, $language); |
||
| 26 | } |
||
| 27 | |||
| 28 | public static function _getReferences($page) { |
||
| 29 | return page::getReferences($page); |
||
| 30 | } |
||
| 31 | |||
| 32 | public static function _stripARNameSpace($page) { |
||
| 33 | return page::stripARNameSpace($page); |
||
| 34 | } |
||
| 35 | |||
| 36 | } |
||
| 37 | |||
| 38 | class page { |
||
| 39 | |||
| 40 | View Code Duplication | private function pregError( $errno ) { |
|
| 41 | switch($errno) { |
||
| 42 | case PREG_NO_ERROR: |
||
| 43 | $result = 'There is no error.'; |
||
| 44 | break; |
||
| 45 | case PREG_INTERNAL_ERROR: |
||
| 46 | $result = 'There is an internal error!'; |
||
| 47 | break; |
||
| 48 | case PREG_BACKTRACK_LIMIT_ERROR: |
||
| 49 | $result = 'Backtrack limit was exhausted!'; |
||
| 50 | break; |
||
| 51 | case PREG_RECURSION_LIMIT_ERROR: |
||
| 52 | $result = 'Recursion limit was exhausted!'; |
||
| 53 | break; |
||
| 54 | case PREG_BAD_UTF8_ERROR: |
||
| 55 | $result = 'Bad UTF8 error!'; |
||
| 56 | break; |
||
| 57 | case PREG_BAD_UTF8_OFFSET_ERROR: |
||
| 58 | $result = 'Bad UTF8 offset error!'; |
||
| 59 | break; |
||
| 60 | default: |
||
| 61 | $result = 'Unknown preg errno '.$errno; |
||
| 62 | } |
||
| 63 | return $result; |
||
| 64 | } |
||
| 65 | |||
| 66 | 12 | public static function getBody($page) { |
|
| 67 | View Code Duplication | if (stripos($page, "</body") !== false) { |
|
| 68 | $page = preg_replace('|</BODY.*$|is', '', $page); |
||
| 69 | $errno = preg_last_error(); |
||
| 70 | if( $page === null || $errno != PREG_NO_ERROR ){ |
||
| 71 | debug('preg_replace returned null errno '. $errno .' in ' . |
||
| 72 | 12 | __CLASS__ . ':' . __FUNCTION__ . ':' . __LINE__ . '?'); |
|
| 73 | debug('preg error:'. page::pregError($errno)); |
||
| 74 | 12 | return '<!-- Error: Backtrack limit was exhausted (531) -->'; |
|
| 75 | } |
||
| 76 | } |
||
| 77 | View Code Duplication | if (stripos($page, "<body") !== false) { |
|
| 78 | $page = preg_replace('/^.*<BODY[^>]*>/is', '', $page); |
||
| 79 | $errno = preg_last_error(); |
||
| 80 | if( $page === null || $errno != PREG_NO_ERROR ){ |
||
| 81 | debug('preg_replace returned null, errno '. $errno .' in ' . |
||
| 82 | __CLASS__ . ':' . __FUNCTION__ . ':' . __LINE__ . '?'); |
||
| 83 | debug('preg error:'. page::pregError($errno)); |
||
| 84 | return '<!-- Error: Backtrack limit was exhausted (532) -->'; |
||
| 85 | } |
||
| 86 | } |
||
| 87 | return $page; |
||
| 88 | } |
||
| 89 | |||
| 90 | View Code Duplication | public static function parse($page, $full=false) { |
|
| 91 | $context = pobject::getContext(); |
||
| 92 | $me = $context["arCurrentObject"]; |
||
| 93 | include_once($me->store->get_config('code')."modules/mod_url.php"); |
||
| 94 | if (!$full) { |
||
| 95 | $page = page::getBody($page); |
||
| 96 | } |
||
| 97 | return URL::ARtoRAW($page); |
||
| 98 | } |
||
| 99 | |||
| 100 | public static function isEmpty($page) { |
||
| 101 | $page = page::getBody($page); |
||
| 102 | return trim(str_replace(' ',' ',strip_tags($page, '<img><object><embed><iframe>')))==''; |
||
| 103 | } |
||
| 104 | |||
| 105 | public static function clean($page, $settings=false) { |
||
| 106 | global $AR; |
||
| 107 | global $ARCurrent; |
||
| 108 | $context = pobject::getContext(); |
||
| 109 | $me = $context["arCurrentObject"]; |
||
| 110 | |||
| 111 | View Code Duplication | if( !$settings ) { |
|
| 112 | if (!$ARCurrent->arEditorSettings) { |
||
| 113 | $settings = $me->call("editor.ini"); |
||
| 114 | } else { |
||
| 115 | $settings = $ARCurrent->arEditorSettings; |
||
| 116 | } |
||
| 117 | } |
||
| 118 | |||
| 119 | View Code Duplication | if ($settings["htmlcleaner"]["enabled"] || $settings["htmlcleaner"]===true) { |
|
| 120 | require_once($me->store->get_config("code")."modules/mod_htmlcleaner.php"); |
||
| 121 | $config = $settings["htmlcleaner"]; |
||
| 122 | $page = htmlcleaner::cleanup($page, $config); |
||
| 123 | } |
||
| 124 | |||
| 125 | View Code Duplication | if ($settings["htmltidy"]["enabled"] || $settings["htmltidy"]===true) { |
|
| 126 | require_once($me->store->get_config("code")."modules/mod_tidy.php"); |
||
| 127 | if ($settings["htmltidy"]===true) { |
||
| 128 | $config = array(); |
||
| 129 | $config["options"] = $AR->Tidy->options; |
||
| 130 | } else { |
||
| 131 | $config = $settings["htmltidy"]; |
||
| 132 | } |
||
| 133 | $config["temp"] = $me->store->get_config("files")."temp/"; |
||
| 134 | $config["path"] = $AR->Tidy->path; |
||
| 135 | $tidy = new ARtidy($config); |
||
| 136 | $result = $tidy->clean($page); |
||
| 137 | $page = $result["html"]; |
||
| 138 | } |
||
| 139 | |||
| 140 | if ($settings["allow_tags"]) { |
||
| 141 | $page = strip_tags($page, $settings["allow_tags"]); |
||
| 142 | } |
||
| 143 | |||
| 144 | return $page; |
||
| 145 | } |
||
| 146 | |||
| 147 | 12 | View Code Duplication | public static function compile($page, $language='') { |
| 148 | 12 | $context = pobject::getContext(); |
|
| 149 | 12 | $me = $context["arCurrentObject"]; |
|
| 150 | 12 | include_once($me->store->get_config('code')."modules/mod_url.php"); |
|
| 151 | 12 | include_once($me->store->get_config('code')."modules/mod_htmlparser.php"); |
|
| 152 | 12 | if (!$language) { |
|
| 153 | $language = $me->nls; |
||
| 154 | } |
||
| 155 | 12 | $page = URL::RAWtoAR($page, $language); |
|
| 156 | 12 | $newpage = $page; |
|
| 157 | 12 | $nodes = htmlparser::parse($newpage, array('noTagResolving' => true)); |
|
| 158 | // FIXME: the isChanged check is paranoia mode on. New code ahead. |
||
| 159 | // will only use the new compile method when it is needed (htmlblocks) |
||
| 160 | // otherwise just return the $page, so 99.9% of the sites don't walk |
||
| 161 | // into bugs. 21-05-2007 |
||
| 162 | 12 | $isChanged = page::compileWorker($nodes); |
|
| 163 | 12 | if ($isChanged) { |
|
| 164 | return htmlparser::compile($nodes); |
||
| 165 | } else { |
||
| 166 | 12 | return $page; |
|
| 167 | } |
||
| 168 | } |
||
| 169 | |||
| 170 | 12 | public static function compileWorker(&$node) { |
|
| 171 | 12 | $result = false; |
|
| 172 | 12 | $contentEditable = ""; |
|
| 173 | 12 | View Code Duplication | if (isset($node['attribs']['contenteditable'])) { |
| 174 | $contentEditable = "contenteditable"; |
||
| 175 | 12 | } else if (isset($node['attribs']['contentEditable'])) { |
|
| 176 | $contentEditable = "contentEditable"; |
||
| 177 | } |
||
| 178 | 12 | View Code Duplication | if ($contentEditable) { |
| 179 | $node['attribs']['ar:editable'] = $node['attribs'][$contentEditable]; |
||
| 180 | unset($node['attribs'][$contentEditable]); |
||
| 181 | $result = true; |
||
| 182 | } |
||
| 183 | 12 | View Code Duplication | if ($node['attribs']['ar:type'] == "template") { |
| 184 | $path = $node['attribs']['ar:path']; |
||
| 185 | $template = $node['attribs']['ar:name']; |
||
| 186 | $argsarr = array(); |
||
| 187 | if (is_array($node['attribs'])) { |
||
| 188 | foreach ($node['attribs'] as $key => $value) { |
||
| 189 | if (substr($key, 0, strlen('arargs:')) == 'arargs:') { |
||
| 190 | $name = substr($key, strlen('arargs:')); |
||
| 191 | $argsarr[$name] = $name."=".$value; |
||
| 192 | } |
||
| 193 | } |
||
| 194 | } |
||
| 195 | $args = implode('&', $argsarr); |
||
| 196 | |||
| 197 | $node['children'] = array(); |
||
| 198 | $node['children'][] = array( |
||
| 199 | "type" => "text", |
||
| 200 | "html" => "{arCall:$path$template?$args}" |
||
| 201 | ); |
||
| 202 | // return from worker function |
||
| 203 | return true; |
||
| 204 | } |
||
| 205 | 12 | View Code Duplication | if (is_array($node['children'])) { |
| 206 | 12 | foreach ($node['children'] as $key => $child) { |
|
| 207 | // single | makes the following line always run the compileworker |
||
| 208 | // method, while any return true in that method makes $result true |
||
| 209 | $result = $result | page::compileWorker($node['children'][$key]); |
||
| 210 | 12 | } |
|
| 211 | 12 | } |
|
| 212 | 12 | return $result; |
|
| 213 | } |
||
| 214 | |||
| 215 | View Code Duplication | public static function getReferences($page) { |
|
| 216 | $context = pobject::getContext(); |
||
| 217 | $me = $context["arCurrentObject"]; |
||
| 218 | // Find out all references to other objects |
||
| 219 | // (images, links) in this object, so we can |
||
| 220 | // warn the user if he tries to delete/rename |
||
| 221 | // an object which is still referenced somewhere |
||
| 222 | // Use Perl compatible regex for non-greedy matching |
||
| 223 | preg_match_all("/['\"](\{(arSite|arRoot|arBase|arCurrentPage)(\/[a-z][a-z])?}.*?)['\"]/", $page, $matches); |
||
| 224 | $refs = preg_replace( |
||
| 225 | array( |
||
| 226 | "|{arSite(/[a-z][a-z])?}|", |
||
| 227 | "|{arRoot(/[a-z][a-z])?}|", |
||
| 228 | "|{arBase(/[a-z][a-z])?}|", |
||
| 229 | "|{arCurrentPage(/[a-z][a-z])?}|" ), |
||
| 230 | array( |
||
| 231 | $me->currentsite(), |
||
| 232 | "", |
||
| 233 | "", |
||
| 234 | $me->path), |
||
| 235 | $matches[1]); |
||
| 236 | |||
| 237 | $result = array(); |
||
| 238 | foreach ($refs as $ref) { |
||
| 239 | if (substr($ref, -1) != '/' && !$me->exists($ref)) { |
||
| 240 | // Drop the template name |
||
| 241 | $ref = substr($ref, 0, strrpos($ref, "/")+1); |
||
| 242 | } |
||
| 243 | $result[] = $ref; |
||
| 244 | } |
||
| 245 | return $result; |
||
| 246 | } |
||
| 247 | |||
| 248 | View Code Duplication | public static function stripARNameSpace($page) { |
|
| 249 | $context = pobject::getContext(); |
||
| 250 | $me = $context["arCurrentObject"]; |
||
| 251 | include_once($me->store->get_config('code')."modules/mod_htmlcleaner.php"); |
||
| 252 | $cleanAR = array( |
||
| 253 | 'rewrite' => array( |
||
| 254 | '^(A|IMG|DIV)$' => array( |
||
| 255 | '^ar:.*' => false, |
||
| 256 | '^arargs:.*' => false, |
||
| 257 | '^class' => array( |
||
| 258 | 'htmlblock[ ]*uneditable[ ]*' => false |
||
| 259 | ), |
||
| 260 | '^data-vedor-*' => false |
||
| 261 | ) |
||
| 262 | ), |
||
| 263 | 'delete_emptied' => array( |
||
| 264 | 'div', 'a' |
||
| 265 | ) |
||
| 266 | ); |
||
| 267 | return htmlcleaner::cleanup( $page, $cleanAR ); |
||
| 268 | } |
||
| 269 | |||
| 270 | } |
||
| 271 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.