Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Fix #978
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Posselt committed Apr 19, 2016
1 parent e2637ac commit a0b0aee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
owncloud-news (8.7.1)
* **Bugfix**: Send Chrome's user agent string instead of our own since mod_security, which is used on some servers, thinks that only browsers are allowed to send user agents. This will fix feed updates for some websites, e.g. joomla.org, (because we all know that Joomla is big on security ;) ), #978

owncloud-news (8.7.0)
* **Enhancement**: Better lock down Composer versions to prevent shipping newer PHP libraries then intended when compiling the project
* **Enhancement**: Mark current article as active while scrolling
Expand Down
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,29 +215,6 @@ Some hints:
* type clob is usually an Sql TEXT
* length for integer fields means bytes, so an integer with length 8 means its 64bit


### I'm getting a feed not found error when adding a feed, but it works in picoFeed/Miniflux
Some websites block the News app because the mistake its user agent string for an attack (most notably https://www.joomla.org/announcements.feed\?type\=rss). You can test for this issue by changing the default user agent string in **appinfo/application.php**.

Search the section that defines the user agent:

```php
$userAgent = 'ownCloud News/' . $appConfig->getConfig('version') .
' (+https://owncloud.org/; 1 subscriber;)';
```

and replace it with the following line:

```php
$userAgent = 'test';
```

If this fixes the issue, contact the feed's administrators and ask them to fix their server setup.

**Hint**: Should you not be able to set up picoFeed or Miniflux, you can simply use the bundled picoFeed version to test the website, e.g.:

php -f vendor/fguillot/picofeed/picofeed feed https://www.joomla.org/announcements.feed\?type\=rss

### I am getting: Exception: Some\\Class does not exist erros in my owncloud.log
This is very often caused by missing or old files, e.g. by failing to upload all of the News app' files or errors during installation. Before you report a bug, please recheck if all files from the archive are in place and accessible.

Expand Down
20 changes: 17 additions & 3 deletions appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function __construct(array $urlParams=[]) {
/**
* App config parser
*/
/** @noinspection PhpParamsInspection */
$this->registerService(AppConfig::class, function($c) {
$config = new AppConfig(
$c->query(INavigationManager::class),
Expand All @@ -73,14 +74,17 @@ public function __construct(array $urlParams=[]) {
/**
* Core
*/
/** @noinspection PhpParamsInspection */
$this->registerService('LoggerParameters', function($c) {
return ['app' => $c->query('AppName')];
});

/** @noinspection PhpParamsInspection */
$this->registerService('databaseType', function($c) {
return $c->query(IConfig::class)->getSystemValue('dbtype');
});

/** @noinspection PhpParamsInspection */
$this->registerService('ConfigView', function($c) {
$fs = $c->query(IRootFolder::class);
$path = 'news/config';
Expand All @@ -92,6 +96,7 @@ public function __construct(array $urlParams=[]) {
});


/** @noinspection PhpParamsInspection */
$this->registerService(Config::class, function($c) {
$config = new Config(
$c->query('ConfigView'),
Expand All @@ -102,6 +107,7 @@ public function __construct(array $urlParams=[]) {
return $config;
});

/** @noinspection PhpParamsInspection */
$this->registerService(HTMLPurifier::class, function($c) {
$directory = $c->query(IConfig::class)
->getSystemValue('datadirectory') . '/news/cache/purifier';
Expand All @@ -127,14 +133,19 @@ public function __construct(array $urlParams=[]) {
/**
* Fetchers
*/
/** @noinspection PhpParamsInspection */
$this->registerService(PicoFeedConfig::class, function($c) {
// FIXME: move this into a separate class for testing?
$config = $c->query(Config::class);
$appConfig = $c->query(AppConfig::class);
$proxy = $c->query(ProxyConfigParser::class);

$userAgent = 'ownCloud News/' . $appConfig->getConfig('version') .
' (+https://owncloud.org/; 1 subscriber;)';
// use chrome's user agent string since mod_security rules
// assume that only browsers can send user agent strings. This
// can lead to blocked feed updates like joomla.org
// For more information see
// https://www.atomicorp.com/wiki/index.php/WAF_309925
$userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36' .
'(KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36';

$pico = new PicoFeedConfig();
$pico->setClientUserAgent($userAgent)
Expand Down Expand Up @@ -166,6 +177,7 @@ public function __construct(array $urlParams=[]) {
return $pico;
});

/** @noinspection PhpParamsInspection */
$this->registerService(Fetcher::class, function($c) {
$fetcher = new Fetcher();

Expand All @@ -186,6 +198,7 @@ public function __construct(array $urlParams=[]) {
* @param string $file path relative to this file, __DIR__ will be prepended
*/
private function registerFileContents($key, $file) {
/** @noinspection PhpParamsInspection */
$this->registerService($key, function () use ($file) {
return file_get_contents(__DIR__ . '/' . $file);
});
Expand Down Expand Up @@ -217,6 +230,7 @@ private function registerParameter($key, $value) {
* @param string $factory fully qualified factory class name
*/
private function registerFactory($key, $factory) {
/** @noinspection PhpParamsInspection */
$this->registerService($key, function ($c) use ($factory) {
return $c->query($factory)->build();
});
Expand Down

0 comments on commit a0b0aee

Please sign in to comment.