Forum: wxRuby HTMLWindow limits?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0a0d5a13e804e213e37843374c655579?d=identicon&s=25 Vk Dee (vkd)
on 2009-05-13 01:35
Hi,
I'm trying to write a simple email client using wxruby, and using
HTMLWindow to display the email contents. But HtmlWindow seems to have a
limit of 2362 bytes on the size of the page it would load - which I
found emperically by limiting the size of text i passed into the
control. Is this a known problem, or am I setting things wrongly?

Here's the relevant piece of code:

<pre>
class ItemDetail < Panel
  def initialize(parent,items,log)
    super(parent)
    @items=items
    @log=log

    @sizer = Wx::BoxSizer.new(Wx::VERTICAL)
      add_from
    add_message
    set_sizer(@sizer)
  end
  def add_from
    @from=TextCtrl.new(self,-1,"",:name=>"fromtxtctrl")
    @sizer.add(@from,1,Wx::ALL|Wx::GROW)
  end

  def add_message
    @message=HtmlWindow.new(self,:name=>"msghtmlwindow")
    @sizer.add(@message,10,Wx::ALL|Wx::GROW)
  end

  def setItem(index)
    begin
      item=@items[index]
      @from.set_value(item.from)
      #@message.set_value(item.body[0..2362]) #emperically found that
this is the limit for page size.
    rescue Exception => err
      @log.write_text('invalid item index: "%d, or err:%s"'
%[index,err.message])
    end
  end
end

</pre>
0a0d5a13e804e213e37843374c655579?d=identicon&s=25 Vk Dee (vkd)
on 2009-05-13 01:38
Vk Dee wrote:
Correction: the set_value line is not commented out. It should read like
so:
>       @message.set_value(item.body[0..2362]) #emperically found that
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-05-14 15:19
(Received via mailing list)
Vk Dee wrote:
> I'm trying to write a simple email client using wxruby, and using
> HTMLWindow to display the email contents. But HtmlWindow seems to have a
> limit of 2362 bytes on the size of the page it would load - which I
> found emperically by limiting the size of text i passed into the
> control. Is this a known problem, or am I setting things wrongly?
>

No, there is no such limit on the size of text to be displayed.

Does this problem arise with a particular text, or any HTML text? I
would check whether the HTML string you are providing is correctly
encoded in UTF-8 - if not, you might get this kind of truncation at an
invalid byte.
> Here's the relevant piece of code:
>

Thanks for posting code, but it's not possible to check it out unless
it's self-contained and runnable. We can't reconstruct and imagine what
the rest of the program is doing. Often you will find the process of
reducing it to a basic sample illustrating the problem will show up the
root cause.

a
0a0d5a13e804e213e37843374c655579?d=identicon&s=25 Vk Dee (vkd)
on 2009-05-14 23:44
> No, there is no such limit on the size of text to be displayed.
ok
>
> Thanks for posting code, but it's not possible to check it out unless
> it's self-contained and runnable. We can't reconstruct and imagine what
> the rest of the program is doing. Often you will find the process of
> reducing it to a basic sample illustrating the problem will show up the
> root cause.
>
fair enough. i'll try and put in a self-contained sample. and check out
the possibility of rogue html.
Thanks
3396e4a3df8a840faec520af8555a400?d=identicon&s=25 Mario Steele (Guest)
on 2009-05-15 00:13
(Received via mailing list)
Also, keep in mind that HTMLWindow is not a full blown Browser Engine,
like
what you would get with the Mozilla Engine, or IE's ActiveX Control, or
even
WebKit.  HTMLWindow can only handle a small subset of HTML Tags, and is
very
strict in what it will properly interpret.  So make sure your not using
anything that's above HTML 3.0 strict set.  Or something along thoes
lines.
0a0d5a13e804e213e37843374c655579?d=identicon&s=25 Vk Dee (vkd)
on 2009-05-15 02:21
Update: it does look like a case of bad html.
Thanks for the quick response. I'll update this thread if there's
anything new to add.

>>
> fair enough. i'll try and put in a self-contained sample. and check out
> the possibility of rogue html.
> Thanks
0a0d5a13e804e213e37843374c655579?d=identicon&s=25 Vk Dee (vkd)
on 2009-05-15 13:41
Vk Dee wrote:
Final update:
My fix in case anyone has the same problem was to replace all
non-printable characters like so:
htmlstring.gsub(/[^[:print:]]/, '')

> Update: it does look like a case of bad html.
> Thanks for the quick response. I'll update this thread if there's
> anything new to add.
>
This topic is locked and can not be replied to.