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

Comments

@rockwotj
Copy link
Contributor

Example CSS:

dd {
    background-image: cross-fade(20% url(http:https://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
Contributor Author

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
Copy link
Owner

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 commented May 14, 2020

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

@phax
Copy link
Owner

phax commented May 14, 2020

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

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

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants