Commit 44e48c90 authored by Dominik Hebeler's avatar Dominik Hebeler

fixed invalid UTF-8 characters in json response

parent 1a48e785
......@@ -44,6 +44,9 @@ class AdminSpamController extends Controller
public function jsonQueries()
{
$queries = $this->getQueries();
# JSON encoding will fail if invalid UTF-8 Characters are in this string
# mb_convert_encoding will remove thise invalid characters for us
$queries = mb_convert_encoding($queries, "UTF-8", "UTF-8");
return response()->json($queries);
}
......@@ -77,8 +80,10 @@ class AdminSpamController extends Controller
];
}
# JSON encoding will fail if invalid UTF-8 Characters are in this string
# mb_convert_encoding will remove thise invalid characters for us
$resultData = mb_convert_encoding($resultData, "UTF-8", "UTF-8");
return response()->json($resultData);
}
private function getQueries()
......
......@@ -12,7 +12,6 @@ use View;
class MetaGerSearch extends Controller
{
public function search(Request $request, MetaGer $metager, $timing = false)
{
if ($request->filled("chrome-plugin")) {
......@@ -156,7 +155,7 @@ class MetaGerSearch extends Controller
// This might speed up page view time for users with slow network
$responseArray = str_split($resultpage->render(), 1024);
foreach ($responseArray as $responsePart) {
echo ($responsePart);
echo($responsePart);
flush();
}
$requestTime = microtime(true) - $time;
......@@ -182,7 +181,6 @@ class MetaGerSearch extends Controller
if ($request->filled('loadMore') && $request->filled('script') && $request->input('script') === "yes") {
return $this->loadMoreJS($request);
}
}
private function loadMoreJS(Request $request)
......@@ -296,6 +294,10 @@ class MetaGerSearch extends Controller
],
"engines" => $metager->getEngines(),
], 1 * 60);
# JSON encoding will fail if invalid UTF-8 Characters are in this string
# mb_convert_encoding will remove thise invalid characters for us
$result = mb_convert_encoding($result, "UTF-8", "UTF-8");
return response()->json($result);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment