Mayayana
2019-04-29 12:55:57 UTC
Very weird problem. I've been working on an HTA that
allows me to touch-up edit webpages, in WYSIWYG manner.
It starts by loading what's in the BODY into a DIV, then
storing the header and end. When I save changes it takes
the innerHTML from the DIV, adds back the header and end,
and writes to disk with normal Textstream operation.
The whole thing works fine but I was testing it on various
files and came across one (an article from theregister.co.uk
that has no particular odd qualities) that won't work.
I load the page fine but saving changes results in a blank file.
Empty. If I show the 3 parts in msgbox they all look right. If
I right each part to disk, the BODY section is empty but both
ends write OK. When I write the whole file it writes the blank
file and then errors with "invalid procedure call or argument".
That seems to be at Write, though I'm not certain because error
line numbers can be off. The code is in an external VBS.
sMid = MainDiv.innerHTML
sContent = sBeg & sMid & sEnd
Then it calls the Write routine in a class. All very vanilla:
Public Sub WriteFile(sPath, sContent)
'on error resume next
If FSOcc.FileExists(sPath) = True Then FSOcc.DeleteFile sPath, True
Set TScc = FSOcc.CreateTextFile(sPath, True)
TScc.Write sContent
TScc.Close
Set TScc = Nothing
End Sub
The only thing I can even imagine causing trouble would
be a null, but I don't see how a null could get into the text.
Even then, the file should write up to the null. And this happens
even if I've made no edits to the page content. (Though IE
does make edits.) I've also tried removing script before loading.
Nothing works. It always comes out a zero length file.
Here's the webpage, for what it's worth:
https://www.theregister.co.uk/2019/04/26/windows_10_storage/
I just picked it randomly, downloading only the HTML.
allows me to touch-up edit webpages, in WYSIWYG manner.
It starts by loading what's in the BODY into a DIV, then
storing the header and end. When I save changes it takes
the innerHTML from the DIV, adds back the header and end,
and writes to disk with normal Textstream operation.
The whole thing works fine but I was testing it on various
files and came across one (an article from theregister.co.uk
that has no particular odd qualities) that won't work.
I load the page fine but saving changes results in a blank file.
Empty. If I show the 3 parts in msgbox they all look right. If
I right each part to disk, the BODY section is empty but both
ends write OK. When I write the whole file it writes the blank
file and then errors with "invalid procedure call or argument".
That seems to be at Write, though I'm not certain because error
line numbers can be off. The code is in an external VBS.
sMid = MainDiv.innerHTML
sContent = sBeg & sMid & sEnd
Then it calls the Write routine in a class. All very vanilla:
Public Sub WriteFile(sPath, sContent)
'on error resume next
If FSOcc.FileExists(sPath) = True Then FSOcc.DeleteFile sPath, True
Set TScc = FSOcc.CreateTextFile(sPath, True)
TScc.Write sContent
TScc.Close
Set TScc = Nothing
End Sub
The only thing I can even imagine causing trouble would
be a null, but I don't see how a null could get into the text.
Even then, the file should write up to the null. And this happens
even if I've made no edits to the page content. (Though IE
does make edits.) I've also tried removing script before loading.
Nothing works. It always comes out a zero length file.
Here's the webpage, for what it's worth:
https://www.theregister.co.uk/2019/04/26/windows_10_storage/
I just picked it randomly, downloading only the HTML.