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

Validator checks format of xlink html #303

Open
kerimoyle opened this issue Apr 10, 2019 · 4 comments
Open

Validator checks format of xlink html #303

kerimoyle opened this issue Apr 10, 2019 · 4 comments

Comments

@kerimoyle
Copy link
Contributor

I've added a function to check that a given href attribute is valid as a reference, according to the xlink specs ... but ... those specs for urls were quite dependent on where different characters appear in the string. I'm not sure how restrictive this check should actually be for our use cases? And whether %-escaping is permitted?

bool Validator::ValidatorImpl::isValidHTML(const std::string &html) {
    /// @cellml2_5 5.1.1 Check string is a valid html attribute according to XLink specs (maybe too restrictive though?)
    // Allowed characters are ASCII a-z, A-Z, 0-9, as well as #, %, [, ] 
    // (as taken from: https://www.w3.org/TR/2001/REC-xlink-20010627/#link-locators)
    // "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=";
    std::string allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
    allowed += "-_./";
    allowed += "[]#";
    if (html.find_first_not_of(allowed) != std::string::npos) {
        return (false);
    }
    return (true);
}
@nickerso
Copy link
Contributor

I think the validator should simply check that the given href is a valid URI. Since we already have access to libXml2, perhaps easiest to look at using something like xmlParseURI (http:https://www.xmlsoft.org/html/libxml-uri.html#xmlParseURI) to check for a valid URI? Otherwise, for now, a check like the above is probably sufficient, although you'd need to allow the full set of characters (i.e., include :&%? etc.

@agarny
Copy link
Contributor

agarny commented Apr 10, 2019

+1 for xmlParseURI().

@kerimoyle kerimoyle mentioned this issue Apr 11, 2019
@kerimoyle
Copy link
Contributor Author

Closing as is fixed in PR #304

@hsorby
Copy link
Contributor

hsorby commented Apr 17, 2019

We don't close the issue until the code in this repository actually has the fix. That is to say once the PR that addresses this issue is merged.

@hsorby hsorby reopened this Apr 17, 2019
@kerimoyle kerimoyle changed the title xlink html Validator checks format of xlink html May 2, 2019
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

No branches or pull requests

4 participants