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 = "";
|
||||
|
||||
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) {
|
||||
throw $e;
|
||||
}
|
||||
@ -561,7 +563,10 @@ class Bookmarks {
|
||||
//Check for encoding of site.
|
||||
//If not UTF-8 convert it.
|
||||
$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])) {
|
||||
$decodeFrom = strtoupper($encoding[1]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user