Tamás Marcinkovics created KNOX-3556:
----------------------------------------

             Summary: Rewrite: add find option to <apply> so URLs embedded in 
HTML attribute values and <style> text can be rewritten
                 Key: KNOX-3556
                 URL: https://issues.apache.org/jira/browse/KNOX-3556
             Project: Apache Knox
          Issue Type: Task
          Components: Server
    Affects Versions: 3.0.0
            Reporter: Tamás Marcinkovics
            Assignee: Tamás Marcinkovics


Add find mode to rewrite `<apply>` for HTML attributes and text
OpenSearch Dashboards puts its base path into the page as 
`<osd-injected-metadata 
data="\{&quot;basePath&quot;:&quot;/ctx&quot;,&quot;serverBasePath&quot;:&quot;/ctx&quot;,…}">`.
 
The browser JS reads this once at startup and builds every request URL and the 
router base from it, so the value must include the Knox prefix 
(`/gateway/<topology>/ctx`).

Knox rewrites an attribute only when its whole value is a URL, so a URL 
embedded in a JSON attribute value is left unchanged.

Because Knox cannot rewrite inside the attribute, the backend has to be 
configured with the gateway path and topology name. In that page only four 
values need rewriting: `basePath`, `serverBasePath`, `i18n.translationsUrl` and 
`branding.assetFolderUrl`. About 100 font URLs in inline `<style>` are affected 
the same way.

Proposal

Add an optional find attribute to <apply> (default false, so existing service 
definitions are unaffected):

```xml
<content type="*/html">
<apply path="/ctx[^&amp;&quot;'\s\\)]*" find="true" rule="..."/>
</content>
```

When it is set, the HTML reader applies the regex with `Matcher.find()` to 
attribute values and to `<style>` text. It rewrites each match through the 
named rule and leaves the surrounding text untouched. This is the behaviour the 
reader already has for `<script>` text.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to