Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how Parsoid checks domain name #25

Open
kitsook opened this issue Feb 19, 2021 · 0 comments
Open

Fix how Parsoid checks domain name #25

kitsook opened this issue Feb 19, 2021 · 0 comments

Comments

@kitsook
Copy link
Contributor

kitsook commented Feb 19, 2021

MW 1.35 has a new Parsoid implemented in PHP. When preparing the upgrade, we added a hack to get around a domain check issue.

COPY ParsoidHandler_custom_1_35.php /var/www/html/vendor/wikimedia/parsoid/extension/src/Rest/Handler/ParsoidHandler.php

The change uses environment var PARSOID_SKIP_DOAMIN_CHECK to decide if it should skip the domain name check in Parsoid:

// FIXME custom env variable PARSOID_SKIP_DOAMIN_CHECK to skip the check
if ( empty( $this->parsoidSettings['debugApi'] ) && ! filter_var( getenv( 'PARSOID_SKIP_DOAMIN_CHECK' ), FILTER_VALIDATE_BOOLEAN ) ) {
$this->assertDomainIsCorrect( $attribs['envOptions']['domain'] );
}

Why we needed the hack: in our setup, we use Apache to redirect calls to restbase and domain name is hard-coded as localhost, causing the domain name check to fail.

ProxyPass /api/rest_v1 ${RESTBASE_URL}/localhost/v1 nocanon
ProxyPassReverse /api/rest_v1 ${RESTBASE_URL}/localhost/v1 nocanon

Note that the domain check function itself is provisional.

protected function assertDomainIsCorrect( $domain ): void {
// We are cutting some corners here (IDN, non-ASCII casing)
// since domain name support is provisional.
// TODO use a proper validator instead
$wgServer = \RequestContext::getMain()->getConfig()->get( 'Server' );

Reference: 9741576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant