thomthom / SKUI

Ruby wrapper of classes that maps to GUI controls in SketchUp's UI::WebDialogs
MIT License
26 stars 14 forks source link

Add slashes #77

Closed nicolasQbt closed 11 years ago

nicolasQbt commented 11 years ago

I found a bug with the listbox. If I add an item with an apostrophe or quote (this char ' ) and when I select it, this error appear :

private method `split' called for nil:NilClass
…/Kubity/Resources/SKUI/window.rb:284:in `event_callback'
…/Kubity/Resources/SKUI/window.rb:233:in `send'
…/Kubity/Resources/SKUI/window.rb:233:in `add_callback' 

The encodeURIComponent method don't slash the quote char. I add this method to correct the bug

function addslashes(ch) {
    ch = ch.replace(/\\/g,"\\\\")
    ch = ch.replace(/\'/g,"\\'")
    ch = ch.replace(/\"/g,"\\\"")
    return ch
    }

In bridge.js, line 113 :

uri_message = encodeURIComponent( message );
window.location = 'skp:SKUI_Event_Callback@' + addslashes(uri_message);
thomthom commented 11 years ago

Thanks for the report. I'll look into it. I thought the quote character would have been URI encoded.

thomthom commented 11 years ago

Under what platform and browser did that work?

When I try this on OSX 10.8 I still get errors.

thomthom commented 11 years ago

It worked for me if I escaped message before passing to encodeURIComponent.

thomthom commented 11 years ago

@nicolasQbt can you please verify that my submitted fix works for you as well?

nicolasQbt commented 11 years ago

I test it under Windows 7 (browser IE) and when I escape message before encodeURIComponent it does not work. I have to escape it after the encodeURIComponent .

thomthom commented 11 years ago

I've been using Windows 7 IE10 and I cannot reproduce that. I also tried compatibility modes, IE 8 and 9 - but adding slashes before encodeURIComponent is the only way it worked for me.

What IE version do you have?

nicolasQbt commented 11 years ago

Sorry, I upload your last version now, and everything is ok with your correction. encodeURIComponent( message.add_slashes() ); work perfectly.

thomthom commented 11 years ago

Thank you! :+1: