Skip to content

Commit 8e40160

Browse files
committed
fix domain handling
1 parent 5475557 commit 8e40160

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

app/Helper/DomainHelper.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,19 @@
1717
class DomainHelper {
1818
// @return string - the domain name encoded in ASCII-compatible form
1919
public static function encode($string) {
20-
$result = idn_to_ascii($string);
21-
22-
// return the original input if encoding failed
23-
if ($result === false) {
24-
$result = $string;
20+
$result = $string;
21+
if (!empty($string)) {
22+
$result = idn_to_ascii($string);
2523
}
2624

2725
return $result;
2826
}
2927

3028
// @return string - the domain name in Unicode, encoded in UTF-8
3129
public static function decode($string) {
32-
$result = idn_to_utf8($string);
33-
34-
// return the original input if decoding failed
35-
if ($result === false) {
36-
$result = $string;
30+
$result = $string;
31+
if (!empty($string)) {
32+
$result = idn_to_utf8($string);
3733
}
3834

3935
return $result;

app/Http/Controllers/WikiController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function create(Request $request): Response {
5151

5252
// TODO extra validation that username is correct?
5353
$request->validate([
54+
'domain' => 'required',
5455
'sitename' => 'required|min:3',
5556
'username' => 'required',
5657
'profile' => 'nullable|json',

0 commit comments

Comments
 (0)