mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-03-10 10:29:20 +01:00
Improve encoding detection
This commit is contained in:
parent
5535cbbfb5
commit
1dc98e7067
@ -553,7 +553,9 @@ class Bookmarks {
|
|||||||
$page = "";
|
$page = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$page = \OC::$server->getHTTPHelper()->getUrlContent($url);
|
$request = \OC::$server->getHTTPClientService()->newClient()->get($url);
|
||||||
|
$page = $request->getBody();
|
||||||
|
$contentType = $request->getHeader('Content-Type');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
@ -561,8 +563,11 @@ class Bookmarks {
|
|||||||
//Check for encoding of site.
|
//Check for encoding of site.
|
||||||
//If not UTF-8 convert it.
|
//If not UTF-8 convert it.
|
||||||
$encoding = array();
|
$encoding = array();
|
||||||
preg_match('/charset="?(.*?)["|;]/i', $page, $encoding);
|
preg_match('#.+?/.+?;\\s?charset\\s?=\\s?(.+)#i', $contentType, $encoding);
|
||||||
|
if(empty($encoding)) {
|
||||||
|
preg_match('/charset="?(.*?)["|;]/i', $page, $encoding);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($encoding[1])) {
|
if (isset($encoding[1])) {
|
||||||
$decodeFrom = strtoupper($encoding[1]);
|
$decodeFrom = strtoupper($encoding[1]);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user