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

html: Incorrect quote escaping #7753

Closed
gopherbot opened this issue Apr 10, 2014 · 2 comments
Closed

html: Incorrect quote escaping #7753

gopherbot opened this issue Apr 10, 2014 · 2 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 10, 2014

by markf@wingedpig.com:

I posted this to go-nuts before realizing that this is probably a better place for this.
I apologize for the duplication.

Using code.google.com/p/go.net/html to parse and then re-render a chunk of HTML I
believe results in improper escaping of single quotes within double quotes. Here is a
simple test program that parses and re-renders a bit of HTML:

package main

import (
    "bytes"
    "fmt"
    "log"
    "strings"
    "testing"

    "code.google.com/p/go.net/html"
)

func main() {

    data := `<div style="width:450px; font-family: 'Georgia', 'Times', 'Times New Roman', 'serif';" contenteditable="false">`
    doc, err := html.Parse(strings.NewReader(data))
    if err != nil {
        log.Printf("html.Parse returned %s", err)
        return
    }
    var b bytes.Buffer
    err = Render(&b, doc)
    if err != nil {
        log.Printf("html.Render returned %s", err)
        return
    }

    fmt.Printf("%s\n", b.String())
}

The single quotes are improperly escaped in the re-rendered code. 

I believe the original HTML is valid. I've attached a small patch that fixes the
problem. 


Thanks,
Mark

Attachments:

  1. render.patch (500 bytes)
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Apr 10, 2014

Comment 1 by markf@wingedpig.com:

In the cold light of morning, after a late night of chasing other bugs, I was wrong. The
extra escaping doesn't in fact result in invalid HTML, just HTML that's a little more
ugly. Apologies for the bug report.

Loading

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 10, 2014

Comment 2:

Status changed to Retracted.

Loading

@mikioh mikioh added repo-net and removed repo-net labels Dec 23, 2014
@mikioh mikioh changed the title code.google.com/p/go.net/html: Incorrect quote escaping html: Incorrect quote escaping Jan 4, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants