1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

WebHitTestResult: Expect null href attribute

Patch by Eugene Shalygin

BUG: 404320
This commit is contained in:
David Rosca 2019-02-14 08:44:42 +01:00
parent 8ffd2f20df
commit b508ed2260
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8

View File

@ -48,6 +48,9 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
" return false;"
" return window.getSelection().containsNode(e, true);"
"}"
"function attributeStr(e, a) {"
" return e.getAttribute(a) || '';"
"}"
"var res = {"
" baseUrl: document.baseURI,"
" alternateText: e.getAttribute('alt'),"
@ -63,16 +66,16 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
"var r = e.getBoundingClientRect();"
"res.boundingRect = [r.top, r.left, r.width, r.height];"
"if (e.tagName.toLowerCase() == 'img')"
" res.imageUrl = e.getAttribute('src').trim();"
" res.imageUrl = attributeStr(e, 'src').trim();"
"if (e.tagName.toLowerCase() == 'a') {"
" res.linkTitle = e.text;"
" res.linkUrl = e.getAttribute('href').trim();"
" res.linkUrl = attributeStr(e, 'href').trim();"
"}"
"while (e) {"
" if (res.linkTitle == '' && e.tagName.toLowerCase() == 'a')"
" res.linkTitle = e.text;"
" if (res.linkUrl == '' && e.tagName.toLowerCase() == 'a')"
" res.linkUrl = e.getAttribute('href').trim();"
" res.linkUrl = attributeStr(e, 'href').trim();"
" if (res.mediaUrl == '' && isMediaElement(e)) {"
" res.mediaUrl = e.currentSrc;"
" res.mediaPaused = e.paused;"