sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

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

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 358 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

      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
      • thomthomT Offline
        thomthom
        last edited by

        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
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement