deliverance / Deliverance

Deliverance stitches together HTTP responses to theme your content
https://pypi.org/project/Deliverance/
22 stars 8 forks source link

"rewrite-links" removes base tag from content #9

Open jcbrand opened 12 years ago

jcbrand commented 12 years ago

When using Deliverance 0.6 (with Plone):

If we have a proxy rule like this:

  <proxy path="wildcard:*">
    <dest href="http://localhost:8080" />
    <response rewrite-links="1" />
  </proxy>

And then we replace the theme head with the content head:

<replace content="/html/head" theme="/html/head" />

With "rewrite-links" enabled, the <base> tag is stripped from the content head and not inserted into the theme, with "rewire-links" off, the <base> tag does appear.

jcbrand commented 12 years ago

Just tested it now with Deliverance 0.6.1, but the problem persists.

ejucovy commented 12 years ago

Looks like this is happening in lxml.html.make_links_absolute -- unless explicitly disabled, that function's default behavior is to use the <base> tag to make the links absolute, and then discard the <base> tag from the resulting document. We could just copy over the logic in lxml.html.resolve_base_href but without the b.drop_tree().

I understand the logic of the current behavior though -- if all the links relative to the base href are made absolute and then rewritten, the base tag presumably doesn't serve any purpose anymore. Could you spell out a case where you'd still want the base tag present after rewriting links?

And, in that case, should the base href itself be rewritten too? (Or, alternatively, should we only rewrite the base href, and leave all other links relative to it?)