Skip to content

html: Incorrect quote escaping #7753

@gopherbot

Description

@gopherbot

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions