Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLING-11352 - Fix parsing of path-only mappings #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

csaboka
Copy link
Contributor

@csaboka csaboka commented Sep 26, 2022

It wasn't possible to add a regular path-only mapping to /etc/map because the sling:match property was mis-parsed as a URI.

It wasn't possible to add a regular path-only mapping to /etc/map
because the sling:match property was mis-parsed as a URI.
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@rombert
Copy link
Contributor

rombert commented Nov 9, 2022

Hi @csaboka - thank you for the PR and apologies for the delay. I guess no one had the time to look into this. I hope to do so next week, the fix seems quite simple but I don't understand all the implications yet.

@rombert
Copy link
Contributor

rombert commented Nov 14, 2022

@csaboka - I tried to figure out whether this is safe to apply. I noticed that at https://github.com/apache/sling-org-apache-sling-resourceresolver/blob/master/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java#L199-L201 we explicitly remove a prefix, would this scenario cause your proposal to behave unexpectedly?

In addition, it would be good if @cziegeler could also take a look.

FTR, the Starter ITs pass with this change, so nothing already tested seems to be broken.

@cziegeler
Copy link
Contributor

Using matches() instead of find() sounds correct to me; however we have some complicated code around it and it is hard to see whether this will break something else somewhere.

@csaboka
Copy link
Contributor Author

csaboka commented Nov 14, 2022

@rombert : I can't say I understand this code completely, either. I'm not even sure if the "if" block you highlighted can ever be entered. MapEntries.ANY_SCHEME_HOST equals "[^/]+/[^/]+", but if the "url" variable contains any square brackets, the isRegExp() check on line 182 will cause an early return. Therefore, we know that the url cannot start with ANY_SCHEME_HOST at that point.

I agree with @cziegeler that this change seems to be right, but there is no easy way to tell if something is subtly depending on the current (IMO broken) behavior.

@rombert rombert self-requested a review March 3, 2023 16:34
@rombert
Copy link
Contributor

rombert commented Mar 3, 2023

I've assigned myself as a reviewer to make sure it's on my TODO. Not sure when I will get around to it, if anyone beats me to it I won't mind :-)

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link

sonarqubecloud bot commented Feb 3, 2024

Copy link

1 similar comment
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants