Arlolra has uploaded a new change for review.
https://gerrit.wikimedia.org/r/208289
Change subject: Host header is unreliable to base resources
......................................................................
Host header is unreliable to base resources
* 14ee6747c40f8f0ae42a2c41609dea712e4447ec didn't get the job done in
production. Varnish passes "parsoid" as the host.
* Use window.location.origin and do this client side.
Change-Id: I99b50c16c4d5a418faa2e298f1cd6f40d7ed5893
---
M api/utils.js
M api/views/layout.html
M api/views/roundtrip.html
3 files changed, 20 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/89/208289/1
diff --git a/api/utils.js b/api/utils.js
index 181b196..8f635ba 100644
--- a/api/utils.js
+++ b/api/utils.js
@@ -84,7 +84,6 @@
return;
} else {
env.responseSent = true;
- data.host = res.req.headers.host;
res.render(template, data);
}
};
diff --git a/api/views/layout.html b/api/views/layout.html
index 94d33f2..e9286bc 100644
--- a/api/views/layout.html
+++ b/api/views/layout.html
@@ -3,8 +3,22 @@
<head>
<meta charset="utf-8">
{{{headers}}}
- <link type='text/css' href="//{{host}}/static/css/style.css"
rel="stylesheet">
- {{{javascripts}}}
+ <script>
+ // Work around the set base element.
+ var els = [{ src: '/static/css/style.css', css: true }];
+ {{{javascripts}}}
+ function load(o) {
+ var el = document.createElement(o.css ? 'link'
: 'script');
+ if (o.css) {
+ el.setAttribute('type', 'text/css');
+ el.setAttribute('rel', 'stylesheet');
+ }
+ el.setAttribute(o.css ? 'href' : 'src',
+ window.location.origin + o.src);
+ document.head.appendChild(el);
+ }
+ els.forEach(load);
+ </script>
</head>
<body>
{{{body}}}
diff --git a/api/views/roundtrip.html b/api/views/roundtrip.html
index c31a11b..a31d6ba 100644
--- a/api/views/roundtrip.html
+++ b/api/views/roundtrip.html
@@ -1,6 +1,8 @@
{{#jsFiles}}
- <script src='//{{host}}/static/js/jquery.js'></script>
- <script src='//{{host}}/static/js/scrolling.js'></script>
+ els = els.concat([
+ { src: '/static/js/jquery.js' },
+ { src: '/static/js/scrolling.js' }
+ ]);
{{/jsFiles}}
<h2>Wikitext parsed to HTML DOM</h2>
--
To view, visit https://gerrit.wikimedia.org/r/208289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I99b50c16c4d5a418faa2e298f1cd6f40d7ed5893
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits