Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • character limitations of "view browse" command

    The stata command

    Code:
    view browse "http://statalist.org"
    opens the given url in the operating system's standard web browser.

    However, when the given url is larger than 246 characters Stata (Version 18.0) doesn't do anything and doesn't produce any error message.

    Code:
    view browse "http://statalist.org/sssssssssss/ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssssssssssss"
    Putting part of the url in a local, and accessing that local in the "view browse"-line, doesn't fix the problem.

    Does anyone know how to fix this? Is this a Stata (intended/unintended) issue or a limitation in the system OS (Windows 11) or Browser (Firefox)?

    Background: I am using an ado that retrieves values from a dataset and adds them as parameters to a url.

    Stata output with "trace on" for the first command:

    Code:
    . view browse "http://statalist.org/ssssssssssssssssssss"
    
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ begin _view_helper ---
    
    - version 12
    
    - syntax [anything(everything)] [, noNew name(name) *]
    
    - if (index("`anything'"', "|") == 0) {`
    
    = if (index("browse "http://statalist.org""', "|") == 0) {`
    
    - if ("\new'" == "" | "`new'"=="new") & "`name'" == "" {`
    
    = if ("" == "" | ""=="new") & "" == "" {
    
    - local name _new
    
    - }
    
    - if ("\new'" == "nonew") & "`name'" == "" {`
    
    = if ("" == "nonew") & "_new" == "" {
    
    local name _nonew
    
    }
    
    - if "\name'" != "" {`
    
    = if "_new" != "" {
    
    - local suffix "##|\name'"`
    
    = local suffix "##|_new"
    
    - }
    
    - }
    
    - if "`anything'"' == "" {`
    
    = if "browse "http://statalist.org""' == "" {`
    
    local anything "help contents"
    
    }
    
    - if "`options'"' == "" {`
    
    = if ""' == "" {`
    
    - _view \anything'`suffix'`
    
    = _view browse "http://statalist.org"##|_new
    
    - }
    
    - else {
    
    _view \anything', `options' `suffix'`
    
    }
    
    . view browse "http://statalist.org/ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss sssssss
    
    > ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssssssssssssssssssssssssssssss
    
    > ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssss"
    
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ begin _view_helper ---
    
    - version 12
    
    - syntax [anything(everything)] [, noNew name(name) *]
    
    - if (index("`anything'"', "|") == 0) {`
    
    = if (index("browse http://statalist.org/ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss `
    
    > ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssssssssssssssssssssssssssssss
    
    > ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssssssssssssssssssssssssssssssssss""', "|") == 0) {
    
    - if ("\new'" == "" | "`new'"=="new") & "`name'" == "" {`
    
    = if ("" == "" | ""=="new") & "" == "" {
    
    - local name _new
    
    - }
    
    - if ("\new'" == "nonew") & "`name'" == "" {`
    
    = if ("" == "nonew") & "_new" == "" {
    
    local name _nonew
    
    }
    
    - if "\name'" != "" {`
    
    = if "_new" != "" {
    
    - local suffix "##|\name'"`
    
    = local suffix "##|_new"
    
    - }
    
    - }
    
    - if "`anything'"' == "" {`
    
    = if "browse "http://statalist.org/ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss sssssss`
    
    > ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssssssssssssssssssssssssssssss
    
    > ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssss""' == "" {
    
    local anything "help contents"
    
    }
    
    - if "`options'"' == "" {`
    
    = if ""' == "" {`
    
    - _view \anything'`suffix'`
    
    = _view browse "http://statalist.org/ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssss
    
    > ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssssssssssssssssssssssssssssss
    
    > ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssssssssssssssssssssssssssss"##|_new
    
    - }
    
    - else {
    
    _view \anything', `options' `suffix'`
    
    }
    
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- end _view_helper ---

  • #2
    Update: It doesn't seem to be a browser issue. The issue (i.e. nothing happening) is the same on Firefox, Edge and Chrome as the standard browser. So it must be a Stata issue or a general Windwos issue.

    Comment


    • #3
      On a Mac (macOS 15.3.2), with
      Code:
      StataNow/MP 18.5 for Mac (Apple Silicon)
      Revision 26 Feb 2025
      the problem is worse: entering the long URL makes Stata crash, i.e. "quit unexpectedly" as macOS likes to say.

      Comment


      • #4
        The limitation of the view browse command to 245 character urls cost me quite some time in debugging. It would be nice if this could be fixed in the future. As a work around, you can start the browser directly with the winexec command, for example on windows:


        Code:
        global Firefox "c:\Program Files\Mozilla Firefox\firefox.exe"     
        winexec $Firefox LONG_URL

        Comment


        • #5
          Code:
          view browse "http://statalist.org/sssssssssss/ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssssssssssss"
          is not a valid URL. A URL cannot contain spaces.

          Originally posted by Hemanshu Kumar View Post
          On a Mac (macOS 15.3.2), with
          Code:
          StataNow/MP 18.5 for Mac (Apple Silicon)
          Revision 26 Feb 2025
          the problem is worse: entering the long URL makes Stata crash, i.e. "quit unexpectedly" as macOS likes to say.
          I believe this bug was fixed in Stata 19 but not yet in Stata 18. We'll look into this.

          The issue is that Stata has a fixed buffer size that stores the command, filename, or URL for the view command. The buffer size was increased recently in Stata 19 to, I believe, around 5K. However, there is no maximum length for a URL defined in the HTTP protocol so the limit varies between browsers and servers. Some of the browsers support URLs of length 32K and longer which is not practical for Stata to support.
          -Chinh Nguyen

          Comment


          • #6
            Alf Luegt : Can you show me a real URL without a plus (+) or equal (=) character that is longer than 246 characters? I would like to experiment with the view browse command.

            Comment


            • #7
              I did experiment with using view browse and three different but valid URLs. My results are:
              1. URL with 124 characters: Stata 19.5 and 18.0: the browser shows the Forum page; Stata 17: the browser opens but without URL (nothing happens)
                Code:
                view browse https://www.statalist.org/forums/forum/general-stata-discussion/general/1774702-character-limitations-of-view-browse-command
              2. URL with 247 characters: Stata 19.5 and 18.0: the browser shows the Forum page; Stata 17: the browser opens but without URL (nothing happens)
                Code:
                view browse https://www.statalist.org/forums/forum/general-stata-discussion/general/1774702-character-limitations-of-view-browse-command?extreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeemly_long
              3. URL with equal sign (171 characters):Stata 19.5, 18.0, and 17: "=exp not allowed" error
                Code:
                view browse https://www.statalist.org/forums/search?q=character+limitations+of+view+browse+command&searchJSON=%7B%22keywords%22%3A%22character+limitations+of+view+browse+command%22%7D
                	=exp not allowed
                	r(101);
              4. URL in double quotes (171 characters): Stata19.5 and 18.0: the browser receives the URL in double quotes prefixed by file:// and the path of the current working directory resulting in a "page not found" error of the browser; Stata 17: the browser opens but without URL (nothing happens)
                Code:
                view browse "https://www.statalist.org/forums/search?q=character+limitations+of+view+browse+command&searchJSON=%7B%22keywords%22%3A%22character+limitations+of+view+browse+command%22%7D"
              Browser: Firefox; operating system: Linux (Ubuntu 20.04)
              Last edited by Dirk Enzmann; 18 Aug 2025, 10:06. Reason: Correction of code actually used in example 1

              Comment


              • #8
                As an aside to Alf Luegt : Even at the risk of appearing intrusive: Is Alf Luegt your real name? If so, I can imagine that you experience many strange situations in German-speaking countries when you give your name.

                Please note that for good reasons the Stata Forum requests that people use full real names: https://www.statalist.org/forums/help#realnames

                Comment

                Working...
                X