Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
44e48c90
Commit
44e48c90
authored
Oct 14, 2020
by
Dominik Hebeler
Browse files
fixed invalid UTF-8 characters in json response
parent
1a48e785
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/AdminSpamController.php
View file @
44e48c90
...
...
@@ -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
()
...
...
app/Http/Controllers/MetaGerSearch.php
View file @
44e48c90
...
...
@@ -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
);
}
...
...
Dominik Hebeler
@dominik
mentioned in commit
cca86596
·
Oct 26, 2020
mentioned in commit
cca86596
mentioned in commit cca865961811764bdaf8a78fe9195dcdacd3539b
Toggle commit list
Dominik Hebeler
@dominik
mentioned in merge request
!1726 (merged)
·
Oct 26, 2020
mentioned in merge request
!1726 (merged)
mentioned in merge request !1726
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment