• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Get form data from webdialogs?

Scheduled Pinned Locked Moved Developers' Forum
27 Posts 11 Posters 1.3k Views 11 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.
  • T Offline
    TIG Moderator
    last edited by 10 Nov 2011, 11:51

    OK how about 'newline' ?

              $("select option;selected").each(function () {
                str += $(this).text() + "\n";
              });                 
    
    

    then in Ruby chosen=str.split("\n") ?
    Or even \r or \f ?

    TIG

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 10 Nov 2011, 12:11

      That would be even more unlikely to appear, but it's still possible - for instance the Ruby API will allow \n. Who knows what an importer for instance might put in there when importing from some random data. Or if it takes input from somewhere without sanitising.

      I mean, it's unlikely, but still possible. Where as using an escape character scheme would make it 100% safe. And it's a simple thing as well.

      <span class="syntaxdefault">def escape_pipe</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> string </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  string</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">gsub</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'\\'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'\\\\'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">gsub</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'|'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'\\|'</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">end<br /><br />def restore_pipe</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> string </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  string</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">gsub</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'\\\\'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'\\'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">string</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">gsub</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'\\|'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'|'</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">end<br /></span>
      

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

      1 Reply Last reply Reply Quote 0
      • B Offline
        bigcatln
        last edited by 17 Nov 2011, 07:55

        so far there is no elegant solution for it!
        Javascript may be useful but have problem when handling mutibyte characters

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 17 Nov 2011, 08:28

          @bigcatln said:

          so far there is no elegant solution for it!
          Javascript may be useful but have problem when handling mutibyte characters

          Eh? Javascript is unicode compatible... Ruby on the other hand, the 1.8 branch we're stuck with in SU, only deal with strings as ASCII characters.

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

          1 Reply Last reply Reply Quote 0
          • B Offline
            bigcatln
            last edited by 19 Nov 2011, 10:14

            The problem is JSON doen't support Multibyte characters in fact. when you restore Json str from javascript in ruby,it can't be handled correctly

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 19 Nov 2011, 11:52

              @bigcatln said:

              The problem is JSON doen't support Multibyte characters in fact. when you restore Json str from javascript in ruby,it can't be handled correctly

              But that's a problem with Ruby 1.8 which only handle ASCII strings - and not a problem with JavaScript...

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

              1 Reply Last reply Reply Quote 0
              • P Offline
                Pout
                last edited by 28 Nov 2011, 15:34

                I always do as chris does:
                collect in one string, send to SU, split there if needed

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

                Advertisement