[Hawkular-dev] Fwd: [hawkular-ui-services] Slash hell: Preserving the encoded slashes in the resource ids. (#71)

John Mazzitelli mazz at redhat.com
Fri Dec 4 10:48:11 EST 2015


[I'm going to prefix this with - "this is all in my opinion" - if I'm the sole voice in the wilderness on this, I'll shut up.]

Banning characters from resource ID strings that are not valid in URIs is essentially forcing an unnatural limitation on the feeds.

First, feeds don't care that these resource IDs might end up on URLs. But they do care to use a string that identifies a resource (which may contain URI-restricted chars).

Second, hawkular server should not dictate anything about resource IDs that feeds want to set. It should be the feeds that tell the server what they want the IDs to be and the server just uses them. There are going to be third party feeds that will want to set their own IDs and I think you are just going to have to eventually solve this problem anyway (the whole goal of the "feed" system was to make writing feeds the easiest as possible - dictating to the feed authors how they must design their IDs goes against that - IDs should be strings, that's all the restriction we should place on them).

Next you are going to want to put the limitation that resource IDs must be normalized and cannot have parent IDs in them :) but rather IDs should only contain the last address path segment and the resource ancestry should have the rest of the ID parts; thus causing the feeds to no longer have a fully addressable resource ID easy at hand but instead feeds would now be required to do the extra steps of either calculating full addresses for resources by crawling the ancestor tree and performing string manipulation or be forced to add another piece of redundant data to hold a pre-calculated full address. In other words, making the life of the feed author harder.

I say err on the side of cleaner, easier to write and maintain code for the feed author, which will also tend to make it more efficient at runtime (since there will be no need for extra string manipulation). And it will make less hoops that community-developed feed developers will have to jump through. In other words, let us do some up-front extra work and free the feed developer from having to do extra work to encode IDs so they are acceptable to Hawkular.

Is this really just so we can support pretty REST URLs (which I assume the customer never sees, right?) Are there other reasons for wanting this restriction? Because it really shouldn't be a problem to allow encoded REST URLs.

----- Original Message -----
> 
> Before we implement this - should we finally
> go and ban characters that are not valid in URIs
> in a literal way (see RFC 2396)?
> 
> reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
>                      "$" | ","
> 
> Also:
> 
> 2.4.3. Excluded US-ASCII Characters
> 
> control     = <US-ASCII coded characters 00-1F and 7F hexadecimal>
> delims      = "<" | ">" | "#" | "%" | <">
> unwise      = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
> 
> Data corresponding to excluded characters must be escaped in order to
>     be properly represented within a URI.
> 
> 
> 
> 
> > From: Jirka Kremser <notifications at github.com>
> > To: hawkular/hawkular-ui-services
> > <hawkular-ui-services at noreply.github.com>
> > Subject: [hawkular-ui-services] Slash hell: Preserving the encoded
> > slashes in the resource ids.  (#71)
> > Date: Fri, 04 Dec 2015 06:53:17 -0800
> >
> > Currently the interceptor replaces all the encoded slashes to the
> > simple ones, but we need to have the way to pass the encoded slash in
> > the resource id. If the resource id is manually encoded with
> > window.encodeURI() and then angular does it once more for the
> > 'percent' symbol, it ends up as '%252F' here we turn it back to simple
> > '%2F' for which the inventory backend is prepared. In short: '/' are
> > allowed as resource separators: r1/r2/r3 and '%2F' are allowed in the
> > resource ids: r%2F1/r%2F2
> >
> > @ammendonca could you please check?
> > You can view, comment on, or merge this pull request online at:
> >
> > https://github.com/hawkular/hawkular-ui-services/pull/71
> >
> > -- Commit Summary --
> >
> > * Preserving the encoded slashes in the resource ids. Currently the
> > interceptor replaces all the encoded slashes to the simple ones, but
> > we need to have the way to pass the encoded slash in the resource id.
> > If the resource id is manually encoded with window.encodeURI() and
> > then angular does it once more for the 'percent' symbol, it ends up as
> > '%252F' here we turn it back to simple '%2F' for which the inventory
> > backend is prepared. In short: '/' are allowed as resource separators:
> > r1/r2/r3 and '%2F' are allowed in the resource ids: r%2F1/r%2F2
> >
> > -- File Changes --
> >
> >  M src/rest/hawkRest-inventory-provider.ts (10)
> >
> > -- Patch Links --
> >
> > https://github.com/hawkular/hawkular-ui-services/pull/71.patch
> > https://github.com/hawkular/hawkular-ui-services/pull/71.diff
> >
> > ---
> > Reply to this email directly or view it on GitHub:
> > https://github.com/hawkular/hawkular-ui-services/pull/71
> _______________________________________________
> hawkular-dev mailing list
> hawkular-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hawkular-dev
> 


More information about the hawkular-dev mailing list