-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
[MRG+1] Various FormRequest tests+fixes #1597
Conversation
Current coverage is
|
Awesome, thanks! |
'|descendant::input[@type!="submit" and @type!="image" and @type!="reset"' | ||
'and ((@type!="checkbox" and @type!="radio") or @checked)]') | ||
'|descendant::input[not(@type) or @type[' | ||
' translate(., "SUBMIT", "submit") != "submit"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lxml has support for EXSLT regex extensions:
https://stackoverflow.com/questions/2755950/how-to-use-regular-expression-in-lxml-xpath
http://exslt.org/regexp/functions/test/index.html
boolean regexp:test(string, string, 'i')
I think it would be easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re:test(@type, "^(submit|image|reset)$", "i")
only for the first 3
and separately the checkbox and the radio.
Alternatively it's a regexp per value.
I didn't test it but I think there should be a performance penalty
invoking python's re module instead of leaving it to libxml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" there should be a performance penalty"
probably. I'd be curious to see a comparison.
and I'd still go for the regexp version for readability
I changed it according to @redapple's suggestion. |
@redapple what do you think about the new implementation? |
@Digenis , @kmike , FWIW, I was thinking of something like
|
Is there something left to do for this PR? |
[MRG+1] Various FormRequest tests+fixes
#1595 FormRequest should consider input type values case-insensitive
#1596 FormRequest doesn't handle input elements without type attribute
Plus: I noticed a maybe-unicode xpath wasn't encoded
when raising an exception whose
str
message is formatting it with %s.