Browse Source

Be explicit with HTTP challenge character encoding

phpunit-8
J. King 3 weeks ago
parent
commit
5f993187ea
3 changed files with 4 additions and 3 deletions
  1. 1
    0
      CHANGELOG
  2. 1
    1
      lib/REST.php
  3. 2
    2
      tests/cases/REST/TestREST.php

+ 1
- 0
CHANGELOG View File

@@ -6,6 +6,7 @@ Bug fixes:
- Don't fail adding a feed which collides with another via redirection
- Don't fail on very long text-search queries containing question marks
when using PostgreSQL or MySQL
- Specify HTTP authentication encoding as UTF-8

Changes:
- Include a user manual

+ 1
- 1
lib/REST.php View File

@@ -150,7 +150,7 @@ class REST {

public function challenge(ResponseInterface $res, string $realm = null): ResponseInterface {
$realm = $realm ?? Arsse::$conf->httpRealm;
return $res->withAddedHeader("WWW-Authenticate", 'Basic realm="'.$realm.'"');
return $res->withAddedHeader("WWW-Authenticate", 'Basic realm="'.$realm.'", charset="UTF-8"');
}

public function normalizeResponse(ResponseInterface $res, RequestInterface $req = null): ResponseInterface {

+ 2
- 2
tests/cases/REST/TestREST.php View File

@@ -97,10 +97,10 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
self::setConf();
$r = new REST();
$in = new EmptyResponse(401);
$exp = $in->withHeader("WWW-Authenticate", 'Basic realm="OOK"');
$exp = $in->withHeader("WWW-Authenticate", 'Basic realm="OOK", charset="UTF-8"');
$act = $r->challenge($in, "OOK");
$this->assertMessage($exp, $act);
$exp = $in->withHeader("WWW-Authenticate", 'Basic realm="'.Arsse::$conf->httpRealm.'"');
$exp = $in->withHeader("WWW-Authenticate", 'Basic realm="'.Arsse::$conf->httpRealm.'", charset="UTF-8"');
$act = $r->challenge($in);
$this->assertMessage($exp, $act);
}

Loading…
Cancel
Save