• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Ruby - WebDialog.set_html() and string with null character

Scheduled Pinned Locked Moved Developers' Forum
2 Posts 2 Posters 339 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    dolzenko
    last edited by 14 Apr 2009, 16:53

    When the string containing null character is passed to WebDialog.set_html() the page is loaded up to this characted.

    Here is the test case:

    NASTY_STRING = "asd\000dsa"
    
    UI.menu("Plugins").add_item("test set_html") do
    	dlg = UI;;WebDialog.new("test set_html", true);
    	dlg.set_html(NASTY_STRING)
    	dlg.show() # only "asd" is displayed
    end
    
    UI.menu("Plugins").add_item("test set_file") do
    	dlg = UI;;WebDialog.new("test set_file", true);
    	temp_file = ENV['TEMP'] + "\\test_set_file.html"
    	File.open(temp_file, "wb") do |file|
    		file.write(NASTY_STRING)
    	end	
    	dlg.set_file(temp_file) # only "asddsa" is displayed
    	dlg.show()
    end
    

    I understand this is pretty nasty edge case, but still can produce mind boggling results/surprises.

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 14 Apr 2009, 17:21

      NULL characters aren't allowed in HTML. And NULL characters are in C (I think) used to terminate a string.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        1/2
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement