Unihedro / JavaBot

Java based chat bot that runs in Java room of Stack Overflow Chat.
Apache License 2.0
15 stars 4 forks source link

Merge fix-issue33 with master to fix issue #33. #36

Closed Unihedro closed 9 years ago

Unihedro commented 9 years ago

I'm not sure if it actually works consistently though, and plus it could sure use a review. I've used HTTP requests instead of using the browser window of HTMLUnit, as the Stack Exchange login page generates a dynamic iframe, which is not possible to handle directly. Since the login method stands out of its own as it doesn't use the browser, I've isolated the code into its own method and called it when necessary.

Vogel612 commented 9 years ago

Currently trying to login with openid results in a SAXParseException, because the HTML of the login page is invalid:

        <script type="text/javascript">common.bustFrames();</script>            
        <link rel="openid.server" href="https://openid.stackexchange.com/openid/provider">
        <link rel="openid2.provider" href="https://openid.stackexchange.com/openid/provider">
</head>

With the following stacktrace:

[Fatal Error] :16:7: The element type "link" must be terminated by the matching 
end-tag "</link>".
Apr 04, 2015 3:04:02 PM com.gmail.inverseconduit.chat.StackExchangeChat openIdLo
gin
SEVERE: Parsing response text as DOM has caused a parse exception.
org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 7; The element type
 "link" must be terminated by the matching end-tag "</link>".
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
    at com.gmail.inverseconduit.chat.StackExchangeChat.openIdLogin(Unknown Source)
    at com.gmail.inverseconduit.chat.StackExchangeChat.login(Unknown Source)
    at com.gmail.inverseconduit.Main.main(Unknown Source)
Vogel612 commented 9 years ago

This cannot be completed as of now, since the used DOM-Parser is not resilient enough to properly parse the served login pages for the required data.

Unbalanced Tags should be ignored or corrected on a best-effort basis when parsing malformed HTML as it is served on the relevant login pages.

Vogel612 commented 9 years ago

Deferred until further notice, because completion of http://github.com/Unihedro/JChatExchange makes this moot