回答編集履歴
3
修正
test
CHANGED
File without changes
|
2
修正
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
$q = http_build_query([
|
42
42
|
|
43
|
-
'
|
43
|
+
'id' => filter_input(INPUT_GET, 'hoge', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE),
|
44
44
|
|
45
45
|
], '', '&');
|
46
46
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
```php
|
58
58
|
|
59
|
-
header("Location: timeline_edit.php?
|
59
|
+
header("Location: timeline_edit.php?id=" . urlencode(filter_input(INPUT_GET, 'hoge')));
|
60
60
|
|
61
61
|
```
|
62
62
|
|
1
追記
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
```php
|
2
2
|
|
3
|
-
header("Location:timeline_edit.php?id={$_REQUEST['hoge']}");
|
3
|
+
header("Location: timeline_edit.php?id={$_REQUEST['hoge']}");
|
4
4
|
|
5
5
|
```
|
6
6
|
|
@@ -12,6 +12,56 @@
|
|
12
12
|
|
13
13
|
```php
|
14
14
|
|
15
|
-
header("Location:timeline_edit.php?id=$_REQUEST[hoge]");
|
15
|
+
header("Location: timeline_edit.php?id=$_REQUEST[hoge]");
|
16
16
|
|
17
17
|
```
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
但し,
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
- そもそもリクエストパラメータがミックスされる `$_REQUEST` は使うべきではなく, `$_GET` あるいは `$_POST` で代替すべき
|
26
|
+
|
27
|
+
- `isset`での未定義チェックあるいは`filter_input`等でのフィルタリングを行うべき
|
28
|
+
|
29
|
+
- `http_build_query`や`urlencode`でパラメータをエンコードすべき
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
という観点を踏まえると,私なら
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
```php
|
38
|
+
|
39
|
+
// 整数バリデーションし,未定義または失敗時はNULLになる → http_build_queryはNULLを無視する
|
40
|
+
|
41
|
+
$q = http_build_query([
|
42
|
+
|
43
|
+
'hoge' => filter_input(INPUT_GET, 'hoge', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE),
|
44
|
+
|
45
|
+
], '', '&');
|
46
|
+
|
47
|
+
header("Location: timeline_edit.php?$q");
|
48
|
+
|
49
|
+
```
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
と書くことを検討するかもしれません.バリデーションをリダイレクト元でやるのは冗長なので,これを省くにしてもせいぜい
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```php
|
58
|
+
|
59
|
+
header("Location: timeline_edit.php?hoge=" . urlencode(filter_input(INPUT_GET, 'hoge')));
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
ぐらいはやるべきかな,と思います.
|
66
|
+
|
67
|
+
|