Skip to content

website: playground Firefox %25 in URL bug #1770

Closed

Description

@cznic
Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.
N/A

What steps will reproduce the problem?
1. Using Firefox 3.6.17 [Mozilla/5.0 (X11; U; Linux x86_64; cs-CZ; rv:1.9.2.17)
Gecko/20110422 Ubuntu/10.04 (lucid) Firefox/3.6.17] visit golang.org.

2. Enter into the playground's text area:
package main

func main() {
    println("%")
}

3. Verify it's OK by clicking the "COMPILE & RUN" button (or shift-enter).

4. The single percent sign is seen as the correct output of the above program.

5. Click the "Pop Out" link bellow the input yellow text area.


What is the expected output?
A new window with the program as in step 2.


What do you see instead?
A new window with the "Hello World" example.


Which compiler are you using (5g, 6g, 8g, gccgo)?
N/A


Which operating system are you using?
See details in step 1.


Which revision are you using?  (hg identify)
N/A


Please provide any additional information below.
Doing all the same while replacing the percent sign with e.g. a hash sign (#) works as
expected. The problem seems to be related with the value %25 in the escaped URL in the
pop out window. Additionally, everything works (both with % and with #) OK in a Chrome
browser [11.0.696.57 beta]. Other browsers were not tested.

Activity

  1. rsc commented on May 2, 2011

    @rsc
    Contributor

    Comment 1:

    Owner changed to @adg.

    Status changed to Accepted.

  2. bradfitz commented on May 2, 2011

    @bradfitz
    Contributor

    Comment 2:

    This this a Firefox bug?
    Does look like it can be worked around (in both Chrome and Firefox) by keeping # as # in
    the URL:
    This works in both browsers:
    http://golang.org/doc/play/#package%20main%0Afunc%20main()%20%7B%0A%09println(%22#%22)%0A%7D%0A
  3. rsc commented on May 2, 2011

    @rsc
    Contributor

    Comment 3:

    # is not the problem; % is.
    This URL:
    http://golang.org/doc/play/#package%20main%0Afunc%20main()%20%7B%0A%09println(%22%25%22)%0A%7D%0A
    works in Chrome, not in Firefox.
  4. cznic commented on May 2, 2011

    @cznic
    ContributorAuthor

    Comment 4:

    Re #2: I was not able to detect the specific place of the bug. I haven't found anything
    wrong in the playground Javascript code.
    There's probably a small misunderstanding - the workaround solves the working (#) case,
    the problem is with the percent sign (%) instead.
  5. cznic commented on Jun 7, 2011

    @cznic
    ContributorAuthor

    Comment 5:

    A workaround for anyone also having the problem with FF. Not nice, just works.
    http://golang.org/doc/play/#package%20main%0Afunc%20main%28%29%20{%0A%09println%28%22\x25%22%29%0A}%0A
    BTW: If there is some way for me to help with solving this issue, I'l be happy to
    volunteer.
  6. rsc commented on Jul 25, 2011

    @rsc
    Contributor

    Comment 6:

    Status changed to HelpWanted.

  7. gopherbot commented on Aug 14, 2011

    @gopherbot
    Contributor

    Comment 7 by disposaboy@dby.me:

    Unfortunately this is an issue(probably a bug in at least Gecko based browsers) with the
    behaviour of decodeURIComponent in that it appears to decodes %25 then borks at the
    possibly unexpected % sign. I don't have IE handy to test (and I have no reason to
    expect it to break there) but a possible workaround is to just use escape/unescape as
    opposed to encodeURIComponent/decodeURIComponent. AFAICT that pair simply works.
  8. rsc commented on Oct 6, 2011

    @rsc
    Contributor

    Comment 8:

    // Called directly by OS as signal handler.
    #pragma textflag 7
    before the definition of runtime.sigignore in both freebsd/386/signal.c and
    freebsd/amd64/signal.c.
    This is a difference compared to the Darwin port because on Darwin the function gets
    called via sigtramp.  On FreeBSD it is being given to the signal handler directly, so it
    cannot be a typical Go stack-checking function.
  9. gopherbot commented on Oct 20, 2011

    @gopherbot
    Contributor

    Comment 9 by teabee89:

    I found the error. It is indeed a bug in Firefox when retrieving the hash through
    window.location.hash.
    I found a cross-platform solution for the same purpose.
    So to fix the issue, we need to replace line 163 in playground.js by the following :
    var hash = location.href.split("#")[1] || "";
  10. adg commented on Oct 22, 2011

    @adg
    Contributor

    Comment 10:

    Thanks for the fix. I will apply it when I update the playground in the near future.

    Status changed to Started.

  11. rsc commented on Dec 9, 2011

    @rsc
    Contributor

    Comment 11:

    Labels changed: added priority-later.

  12. rsc commented on Jan 29, 2012

    @rsc
    Contributor

    Comment 12:

    adg, did you apply this?
  13. rsc commented on Jan 29, 2012

    @rsc
    Contributor

    Comment 13:

    Labels changed: added priority-go1, removed priority-later.

  14. rsc commented on Jan 30, 2012

    @rsc
    Contributor

    Comment 14:

    Labels changed: added go1-must.

  15. rsc commented on Jan 31, 2012

    @rsc
    Contributor

    Comment 15:

    I fixed this in our internal copy of playground.js, and Andrew promises not to
    reintroduce the bug in his upcoming rewrite.  Thanks very much for diagnosing this.

    Status changed to Fixed.

  16. added this to the Go1 milestone on Apr 10, 2015
  17. locked and limited conversation to collaborators on Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions