[
https://issues.apache.org/jira/browse/KNOX-3556?focusedWorklogId=1054120&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1054120
]
ASF GitHub Bot logged work on KNOX-3556:
----------------------------------------
Author: ASF GitHub Bot
Created on: 11/Nov/26 17:24
Start Date: 11/Nov/26 17:24
Worklog Time Spent: 10m
Work Description: bonampak commented on code in PR #1497:
URL: https://github.com/apache/knox/pull/1497#discussion_r4541081922
##########
gateway-provider-rewrite-common/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteFilterApplyDescriptorImpl.java:
##########
@@ -44,4 +45,23 @@ public String getRule() {
return rule;
}
+ @Override
+ public boolean find() {
+ return find;
+ }
+
+ @Override
+ public UrlRewriteFilterApplyDescriptor find( boolean find ) {
+ this.find = find;
+ return this;
+ }
+
+ public void setFind( boolean find ) {
Review Comment:
With the rename to match="partial|whole", the attribute is an enum parsed
via `Enum.valueOf`, so an invalid value like `match="parttial"` now fails the
rules load instead of silently falling back (same as an invalid flow). This is
covered by `testLoadApplyInvalidMatch`.
A misspelled attribute name is still ignored, but that's Digester's
SetPropertiesRule default for every `rewrite.xml` attribute, so I'd leave it
out of this ticket.
The test revealed that the digester is not cleared after failure, so if a
subsequent load() invocations could fail. I'd keep that as a separate ticket.
Issue Time Tracking
-------------------
Worklog Id: (was: 1054120)
Time Spent: 50m (was: 40m)
> 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
> Priority: Major
> Time Spent: 50m
> Remaining Estimate: 0h
>
> 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="\{"basePath":"/ctx","serverBasePath":"/ctx",…}">{}}}.
> 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.
> h4. Proposal
> Add an optional find attribute to <apply> (default false, so existing service
> definitions are unaffected):
> {{<content type="*/html">}}
> {{<apply path="/ctx[^&"'\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)