sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    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

      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