ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPlainTextHandler Class Reference

A Whoops error handler that prints the same content as the PrettyPageHandler but as plain text. More...

+ Inheritance diagram for ilPlainTextHandler:
+ Collaboration diagram for ilPlainTextHandler:

Public Member Functions

 withExclusionList (array $exclusion_list)
 
 generateResponse ()
 

Protected Member Functions

 getExceptionOutput ()
 Get a short info about the exception. More...
 
 tablesContent ()
 Get the header for the page. More...
 
 tables ()
 Get the tables that should be rendered. More...
 

Protected Attributes

const KEY_SPACE = 25
 

Private Member Functions

 stripNullBytes (string $ret)
 
 hideSensitiveData (array $super_global)
 
 shortenPHPSessionId (array $server)
 

Private Attributes

array $exclusion_list = []
 

Detailed Description

A Whoops error handler that prints the same content as the PrettyPageHandler but as plain text.

This is used for better coexistence with xdebug, see #16627.

Author
Richard Klees richa.nosp@m.rd.k.nosp@m.lees@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

Definition at line 28 of file class.ilPlainTextHandler.php.

Member Function Documentation

◆ generateResponse()

ilPlainTextHandler::generateResponse ( )

Definition at line 50 of file class.ilPlainTextHandler.php.

References getExceptionOutput(), and tablesContent().

50  : string
51  {
52  return $this->getExceptionOutput() . $this->tablesContent() . "\n";
53  }
tablesContent()
Get the header for the page.
getExceptionOutput()
Get a short info about the exception.
+ Here is the call graph for this function:

◆ getExceptionOutput()

ilPlainTextHandler::getExceptionOutput ( )
protected

Get a short info about the exception.

Definition at line 58 of file class.ilPlainTextHandler.php.

Referenced by ilTestingHandler\generateResponse(), and generateResponse().

58  : string
59  {
60  return Formatter::formatExceptionPlain($this->getInspector());
61  }
+ Here is the caller graph for this function:

◆ hideSensitiveData()

ilPlainTextHandler::hideSensitiveData ( array  $super_global)
private
Parameters
array<string,mixed>$super_global
Returns
array<string, mixed>

Definition at line 130 of file class.ilPlainTextHandler.php.

Referenced by tables().

130  : array
131  {
132  foreach ($this->exclusion_list as $parameter) {
133  if (isset($super_global[$parameter])) {
134  $super_global[$parameter] = 'REMOVED FOR SECURITY';
135  }
136 
137  if (isset($super_global['post_vars'][$parameter])) {
138  $super_global['post_vars'][$parameter] = 'REMOVED FOR SECURITY';
139  }
140  }
141 
142  return $super_global;
143  }
+ Here is the caller graph for this function:

◆ shortenPHPSessionId()

ilPlainTextHandler::shortenPHPSessionId ( array  $server)
private
Parameters
array<string,mixed>$server
Returns
array<string, mixed>

Definition at line 149 of file class.ilPlainTextHandler.php.

References ILIAS\LTI\ToolProvider\$key, and $server.

Referenced by tables().

149  : array
150  {
151  $cookie_content = $server['HTTP_COOKIE'];
152  $cookie_content = explode(';', $cookie_content);
153 
154  foreach ($cookie_content as $key => $content) {
155  $content_array = explode('=', $content);
156  if (trim($content_array[0]) === session_name()) {
157  $content_array[1] = substr($content_array[1], 0, 5) . ' (SHORTENED FOR SECURITY)';
158  $cookie_content[$key] = implode('=', $content_array);
159  }
160  }
161 
162  $server['HTTP_COOKIE'] = implode(';', $cookie_content);
163 
164  return $server;
165  }
string $key
Consumer key/client ID value.
Definition: System.php:193
$server
+ Here is the caller graph for this function:

◆ stripNullBytes()

ilPlainTextHandler::stripNullBytes ( string  $ret)
private

Definition at line 45 of file class.ilPlainTextHandler.php.

Referenced by tablesContent().

45  : string
46  {
47  return str_replace("\0", '', $ret);
48  }
+ Here is the caller graph for this function:

◆ tables()

ilPlainTextHandler::tables ( )
protected

Get the tables that should be rendered.

Definition at line 106 of file class.ilPlainTextHandler.php.

References $_COOKIE, $_GET, $_SERVER, $post, $server, hideSensitiveData(), and shortenPHPSessionId().

Referenced by tablesContent().

106  : array
107  {
108  $post = $_POST;
109  $server = $_SERVER;
110 
111  $post = $this->hideSensitiveData($post);
114 
115  return [
116  'GET Data' => $_GET,
117  'POST Data' => $post,
118  'Files' => $_FILES,
119  'Cookies' => $_COOKIE,
120  'Session' => $_SESSION ?? [],
121  'Server/Request Data' => $server,
122  'Environment Variables' => $_ENV,
123  ];
124  }
hideSensitiveData(array $super_global)
$_GET['client_id']
Definition: saml1-acs.php:21
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$server
$_COOKIE[session_name()]
Definition: xapitoken.php:54
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tablesContent()

ilPlainTextHandler::tablesContent ( )
protected

Get the header for the page.

Definition at line 66 of file class.ilPlainTextHandler.php.

References ILIAS\LTI\ToolProvider\$key, stripNullBytes(), and tables().

Referenced by generateResponse().

66  : string
67  {
68  $ret = '';
69  foreach ($this->tables() as $title => $content) {
70  $ret .= "\n\n-- $title --\n\n";
71  if (count($content) > 0) {
72  foreach ($content as $key => $value) {
73  $key = str_pad((string) $key, self::KEY_SPACE);
74 
75  // indent multiline values, first print_r, split in lines,
76  // indent all but first line, then implode again.
77  $first = true;
78  $indentation = str_pad('', self::KEY_SPACE);
79  $value = implode(
80  "\n",
81  array_map(
82  static function ($line) use (&$first, $indentation): string {
83  if ($first) {
84  $first = false;
85  return $line;
86  }
87  return $indentation . $line;
88  },
89  explode("\n", print_r($value, true))
90  )
91  );
92 
93  $ret .= "$key: $value\n";
94  }
95  } else {
96  $ret .= "empty\n";
97  }
98  }
99 
100  return $this->stripNullBytes($ret);
101  }
string $key
Consumer key/client ID value.
Definition: System.php:193
tables()
Get the tables that should be rendered.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withExclusionList()

ilPlainTextHandler::withExclusionList ( array  $exclusion_list)
Parameters
list<string>$exclusion_list

Definition at line 38 of file class.ilPlainTextHandler.php.

References $exclusion_list.

38  : self
39  {
40  $clone = clone $this;
41  $clone->exclusion_list = $exclusion_list;
42  return $clone;
43  }

Field Documentation

◆ $exclusion_list

array ilPlainTextHandler::$exclusion_list = []
private

Definition at line 33 of file class.ilPlainTextHandler.php.

Referenced by withExclusionList().

◆ KEY_SPACE

const ilPlainTextHandler::KEY_SPACE = 25
protected

Definition at line 30 of file class.ilPlainTextHandler.php.


The documentation for this class was generated from the following file: