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

URI Traversing misses uris within functions #59

Closed
rockwotj opened this issue May 14, 2020 · 5 comments
Closed

URI Traversing misses uris within functions #59

rockwotj opened this issue May 14, 2020 · 5 comments
Assignees
Labels
bug

Comments

@rockwotj
Copy link

@rockwotj rockwotj commented May 14, 2020

Example CSS:

dd {
    background-image: cross-fade(20% url(http://example.com/first.png), url(/second.png));
}

I would expect that this example: https://github.com/phax/ph-css/blob/master/ph-css/src/test/java/com/helger/css/supplementary/wiki/WikiVisitDataUrls.java

Would print out urls for this snippet, but it does not.

@rockwotj
Copy link
Author

@rockwotj rockwotj commented May 14, 2020

I'm able to fix this in kotlin with something like:

private inner class CompleteCSSVisitorForUrl(visitor: ICSSUrlVisitor) : CSSVisitorForUrl(visitor) {
        override fun onDeclaration(decl: CSSDeclaration) {
            val expr = decl.expression
            onExpression(decl, expr)
        }

        private fun onExpression(decl: CSSDeclaration, expr: CSSExpression) {
            for (member in expr.allMembers) when (member) {
                is CSSExpressionMemberTermURI -> {
                    visitor.onUrlDeclaration(null, decl, member)
                }
                is CSSExpressionMemberFunction -> {
                    member.expression?.let { onExpression(decl, it) }
                }
            }
        }
    }

Obviously this isn't quite correct WRT to the visitor interface, but works for my usecase.

@phax phax self-assigned this May 14, 2020
@phax phax added the enhancement label May 14, 2020
@phax
Copy link
Owner

@phax phax commented May 14, 2020

Thank you for that snippet 👍
So what you basically suggest is to add a flag "visit nested expressions" in the general visitor and enable this flag by default in the URL Visitor?
There are other patterns as well e.g. in a "math" function an expression can be contained

@phax
Copy link
Owner

@phax phax commented May 14, 2020

Ah forget half of my previous comment. I just fix the CSSVisitorForUrl

@phax phax added bug and removed enhancement labels May 14, 2020
phax added a commit that referenced this issue May 14, 2020
@phax
Copy link
Owner

@phax phax commented May 14, 2020

This is part of the 6.2.3 release that is building as I type

@phax phax closed this May 14, 2020
@rockwotj
Copy link
Author

@rockwotj rockwotj commented May 14, 2020

Wow thanks for the quick turnaround and release here!

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.