angelo-v / wp-linked-data

Wordpress-Plugin to publish blog contents as Linked Data.
7 stars 7 forks source link

Error when http client does not send an Accept header #5

Closed saerdnaer closed 3 years ago

saerdnaer commented 3 years ago

When I enable the wp-linked-data plugin, the following request does not work anymore:

GET /feed/mp3/ HTTP/1.0
Host: andreas-hubel.de
Connection: close
Cache-Control: no-store
Accept-Encoding: gzip
User-Agent: AntennaPod/2.1.3

It results in a 500 error response, with following in the error log:

 PHP Fatal error:  Uncaught Negotiation\Exception\InvalidArgument: The header string should not be empty. in /srv/www/wordpress/wp-content/plugins/wp-linked-data/vendor/willdurand/negotiation/src/Negotiation/AbstractNegotiator.php:23
 Stack trace:
 #0 /srv/www/wordpress/wp-content/plugins/wp-linked-data/request/WilldurandContentNegotiation.php(18): Negotiation\AbstractNegotiator->getBest(NULL, Array)
 #1 /srv/www/wordpress/wp-content/plugins/wp-linked-data/request/RequestInterceptor.php(35): org\desone\wordpress\wpLinkedData\WilldurandContentNegotiation->negotiateRdfContentType(NULL)
 #2 /srv/www/wordpress/wp-includes/class-wp-hook.php(287): org\desone\wordpress\wpLinkedData\RequestInterceptor->intercept(Object(WP))
 #3 /srv/www/wordpress/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
 #4 /srv/www/wordpress/wp-includes/plugin.php(551): WP_Hook->do_action(Array)
 #5 /srv/www/wordpress/wp-includes/class-wp.php(758): do_action_ref_array('wp', Array)
 #6 /srv/www/wordpress/wp-includes/functions.php(1291): WP->main( in /srv/www/wordpress/wp-content/plugins/wp-linked-data/vendor/willdurand/negotiation/src/Negotiation/AbstractNegotiator.php on line 23
angelo-v commented 3 years ago

Thanks for reporting this issue and providing the fix!

I also added a unit test for this case.