File tree 4 files changed +20
-24
lines changed
4 files changed +20
-24
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ There is only 1 page available when you install this script, `index.txt`.
34
34
* In order to view it, open a browser at ` http://localhost/ `
35
35
* Make it editable with ` chmod 666 /var/www/html/code/index.txt ` or directly from your favorite file explorer
36
36
37
- Page names contain only lower-case alpha-numeric characters and dashes (regex ` [\w\-]{1,256 } ` ).
37
+ Page names contain only lower-case alpha-numeric characters and dashes (regex ` [\w\-]{1,128 } ` ).
38
38
Page URLs correspond to text files without the ".txt" extension.
39
39
40
40
3 . Last but not least, [ install ** Docker** ] ( https://docs.docker.com/engine/install/ubuntu/ )
Original file line number Diff line number Diff line change @@ -68,11 +68,11 @@ public function __construct() {
68
68
69
69
if (isset ($ input [self ::REQUEST_PAGE ])) {
70
70
$ methodPage = strtolower (
71
- preg_replace (
72
- '%[^\w\-]+%i ' ,
73
- '' ,
74
- substr ( $ input [ self :: REQUEST_PAGE ], 0 , 256 )
75
- )
71
+ substr (
72
+ preg_replace ( '%[^\w\-]+%i ' , '' , $ input [ self :: REQUEST_PAGE ]) ,
73
+ 0 ,
74
+ 128
75
+ )
76
76
);
77
77
}
78
78
}
@@ -106,7 +106,7 @@ public function __construct() {
106
106
* Write in the code.txt file
107
107
*
108
108
* @var string $content Content - limited in length to self::MAX_INPUT
109
- * @var string $page Page - limited in length to 256 ; pre-sanitized
109
+ * @var string $page Page - limited in length to 128 ; pre-sanitized
110
110
* @throws Exception
111
111
*/
112
112
public function apiWrite ($ content = null , $ page = null ) {
@@ -130,7 +130,7 @@ public function apiWrite($content = null, $page = null) {
130
130
* Execute the code.txt file; limit output size and prevent OOM attack vectors
131
131
*
132
132
* @var string $content (optional) Content - limited in length to self::MAX_INPUT
133
- * @var string $page Page - limited in length to 256 ; pre-sanitized
133
+ * @var string $page Page - limited in length to 128 ; pre-sanitized
134
134
* @return string Output limited in length to self::MAX_OUTPUT
135
135
* @throws Exception
136
136
*/
Original file line number Diff line number Diff line change 1
1
<?php
2
- // Trying to read inside the code repo
3
- if (preg_match ('%^\/?code\/[\w\-]+\.txt$%i ' , $ _SERVER ['REQUEST_URI ' ])) {
4
- header ('HTTP/1.0 404 Not Found ' , true , 404 );
5
- exit ();
6
- }
7
-
8
2
// Prepare the page name
9
3
$ page = strtolower (
10
- preg_replace (
11
- '%[^\w\-]+%i ' ,
12
- '' ,
13
- substr ( $ _SERVER [ ' REQUEST_URI ' ], 0 , 256 )
4
+ substr (
5
+ preg_replace ( '%[^\w\-]+%i ' , '' , $ _SERVER [ ' REQUEST_URI ' ]) ,
6
+ 0 ,
7
+ 128
14
8
)
15
9
);
16
10
28
22
$ titleFragment = (
29
23
strlen ($ page )
30
24
? (
31
- ': '
32
- . implode (
25
+ implode (
33
26
' ' ,
34
27
array_map (
35
28
'ucfirst ' ,
36
29
preg_split (
37
- '%[\s\ _\-]+%i ' ,
30
+ '%[\_\-]+% ' ,
38
31
$ page
39
32
)
40
33
)
41
- )
34
+ ) . ' | PHP Sandbox '
42
35
)
43
- : ' by Mark Jivko '
36
+ : 'PHP Sandbox by Mark Jivko '
44
37
);
45
38
?> <!doctype html>
46
39
<!--
52
45
-->
53
46
<html lang="en">
54
47
<head>
55
- <title>PHP Sandbox <?php echo $ titleFragment ;?> </title>
48
+ <title><?php echo $ titleFragment ;?> </title>
56
49
<meta charset="UTF-8">
57
50
<link rel="stylesheet" href="/css/style.css">
58
51
<link rel="icon" type="image/ico" href="/favicon.ico">
52
+ <meta name="robots" content="noindex" />
59
53
<meta name="Author" content="Mark Jivko">
60
54
<meta name="Description" content="Live coding tool">
61
55
<meta name="apple-mobile-web-app-capable" content="yes">
Original file line number Diff line number Diff line change
1
+ User-agent: *
2
+ Disallow: /
You can’t perform that action at this time.
0 commit comments