Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

website: playground Firefox %25 in URL bug #1770

Closed
cznic opened this issue May 2, 2011 · 15 comments
Closed

website: playground Firefox %25 in URL bug #1770

cznic opened this issue May 2, 2011 · 15 comments
Milestone

Comments

@cznic
Copy link
Contributor

cznic commented May 2, 2011

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.
@rsc
Copy link
Contributor

rsc commented May 2, 2011

Comment 1:

Owner changed to @adg.

Status changed to Accepted.

@bradfitz
Copy link
Contributor

bradfitz commented May 2, 2011

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

@rsc
Copy link
Contributor

rsc commented May 2, 2011

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.

@cznic
Copy link
Contributor Author

cznic commented May 2, 2011

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.

@cznic
Copy link
Contributor Author

cznic commented Jun 7, 2011

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.

@rsc
Copy link
Contributor

rsc commented Jul 25, 2011

Comment 6:

Status changed to HelpWanted.

@gopherbot
Copy link

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.

@rsc
Copy link
Contributor

rsc commented Oct 6, 2011

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.

@gopherbot
Copy link

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] || "";

@adg
Copy link
Contributor

adg commented Oct 22, 2011

Comment 10:

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

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Dec 9, 2011

Comment 11:

Labels changed: added priority-later.

@rsc
Copy link
Contributor

rsc commented Jan 29, 2012

Comment 12:

adg, did you apply this?

@rsc
Copy link
Contributor

rsc commented Jan 29, 2012

Comment 13:

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

@rsc
Copy link
Contributor

rsc commented Jan 30, 2012

Comment 14:

Labels changed: added go1-must.

@rsc
Copy link
Contributor

rsc commented Jan 31, 2012

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.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned adg Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants