diff options
author | nicosomb <nicolas@loeuillet.org> | 2013-04-23 15:25:12 +0200 |
---|---|---|
committer | nicosomb <nicolas@loeuillet.org> | 2013-04-23 15:25:12 +0200 |
commit | 2987031bc3d30437e7b34c3fe912a0ccbcc87f10 (patch) | |
tree | 47b0f7ca59ceb5922ef68d8b74b81e5d539634e6 /inc | |
parent | 3e7188185d9d4be054ed3807c8b910d1e5f504f8 (diff) | |
download | wallabag-2987031bc3d30437e7b34c3fe912a0ccbcc87f10.tar.gz wallabag-2987031bc3d30437e7b34c3fe912a0ccbcc87f10.tar.zst wallabag-2987031bc3d30437e7b34c3fe912a0ccbcc87f10.zip |
Fixed #73 - Can't Poch url with special caracter
Diffstat (limited to 'inc')
-rw-r--r-- | inc/config.php | 1 | ||||
-rw-r--r-- | inc/functions.php | 36 |
2 files changed, 19 insertions, 18 deletions
diff --git a/inc/config.php b/inc/config.php index 8bafd595..737f5215 100644 --- a/inc/config.php +++ b/inc/config.php | |||
@@ -16,6 +16,7 @@ if (!is_dir('db/')) { | |||
16 | 16 | ||
17 | define ('ABS_PATH', 'assets/'); | 17 | define ('ABS_PATH', 'assets/'); |
18 | define ('CONVERT_LINKS_FOOTNOTES', TRUE); | 18 | define ('CONVERT_LINKS_FOOTNOTES', TRUE); |
19 | define ('REVERT_FORCED_PARAGRAPH_ELEMENTS',FALSE); | ||
19 | define ('DOWNLOAD_PICTURES', TRUE); | 20 | define ('DOWNLOAD_PICTURES', TRUE); |
20 | $storage_type = 'sqlite'; # sqlite or file | 21 | $storage_type = 'sqlite'; # sqlite or file |
21 | 22 | ||
diff --git a/inc/functions.php b/inc/functions.php index b830b616..c6cde82f 100644 --- a/inc/functions.php +++ b/inc/functions.php | |||
@@ -39,9 +39,9 @@ function get_external_file($url) | |||
39 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | 39 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
40 | curl_setopt($curl, CURLOPT_HEADER, false); | 40 | curl_setopt($curl, CURLOPT_HEADER, false); |
41 | 41 | ||
42 | // FOR SSL do not verified certificate | 42 | // FOR SSL do not verified certificate |
43 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); | 43 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
44 | curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE ); | 44 | curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE ); |
45 | 45 | ||
46 | // FeedBurner requires a proper USER-AGENT... | 46 | // FeedBurner requires a proper USER-AGENT... |
47 | curl_setopt($curl, CURL_HTTP_VERSION_1_1, true); | 47 | curl_setopt($curl, CURL_HTTP_VERSION_1_1, true); |
@@ -59,14 +59,14 @@ function get_external_file($url) | |||
59 | 59 | ||
60 | // create http context and add timeout and user-agent | 60 | // create http context and add timeout and user-agent |
61 | $context = stream_context_create(array( | 61 | $context = stream_context_create(array( |
62 | 'http'=>array('timeout' => $timeout, | 62 | 'http'=>array('timeout' => $timeout, |
63 | 'header'=> "User-Agent: ".$useragent, /*spoot Mozilla Firefox*/ | 63 | 'header'=> "User-Agent: ".$useragent, /*spoot Mozilla Firefox*/ |
64 | 'follow_location' => true), | 64 | 'follow_location' => true), |
65 | // FOR SSL do not verified certificate | 65 | // FOR SSL do not verified certificate |
66 | 'ssl' => array('verify_peer' => false, | 66 | 'ssl' => array('verify_peer' => false, |
67 | 'allow_self_signed' => true) | 67 | 'allow_self_signed' => true) |
68 | ) | 68 | ) |
69 | ); | 69 | ); |
70 | 70 | ||
71 | // only download page lesser than 4MB | 71 | // only download page lesser than 4MB |
72 | $data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source. | 72 | $data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source. |
@@ -122,19 +122,19 @@ function prepare_url($url) | |||
122 | $i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i); | 122 | $i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i); |
123 | 123 | ||
124 | $title = $url; | 124 | $title = $url; |
125 | $html = Encoding::toUTF8(get_external_file($url,15)); | 125 | $html = Encoding::toUTF8(get_external_file($url,15)); |
126 | // If get_external_file if not able to retrieve HTTPS content try the same URL with HTTP protocol | 126 | // If get_external_file if not able to retrieve HTTPS content try the same URL with HTTP protocol |
127 | if (!preg_match('!^https?://!i', $url) && (!isset($html) || strlen($html) <= 0)) { | 127 | if (!preg_match('!^https?://!i', $url) && (!isset($html) || strlen($html) <= 0)) { |
128 | $url = 'http://' . $url; | 128 | $url = 'http://' . $url; |
129 | $html = Encoding::toUTF8(get_external_file($url,15)); | 129 | $html = Encoding::toUTF8(get_external_file($url,15)); |
130 | } | 130 | } |
131 | 131 | ||
132 | if (isset($html) and strlen($html) > 0) | 132 | if (isset($html) and strlen($html) > 0) |
133 | { | 133 | { |
134 | $r = new Readability($html, $url); | 134 | $r = new Readability($html, $url); |
135 | 135 | ||
136 | $r->convertLinksToFootnotes = CONVERT_LINKS_FOOTNOTES; | 136 | $r->convertLinksToFootnotes = CONVERT_LINKS_FOOTNOTES; |
137 | $r->revertForcedParagraphElements = REVERT_FORCED_PARAGRAPH_ELEMENTS; | 137 | $r->revertForcedParagraphElements = REVERT_FORCED_PARAGRAPH_ELEMENTS; |
138 | 138 | ||
139 | if($r->init()) | 139 | if($r->init()) |
140 | { | 140 | { |