Skip to content

Commit

Permalink
feat: support escaped paths (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Sep 13, 2018
1 parent 5ab0975 commit 48265e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"log"
"net/url"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -94,6 +95,7 @@ func (e *GenericTemplateBasedEncoder) templates() ([]string, error) {
if e.debug {
log.Printf("new template: %q", rel)
}

filenames = append(filenames, rel)
return nil
})
Expand Down Expand Up @@ -135,6 +137,14 @@ func (e *GenericTemplateBasedEncoder) genAst(templateFilename string) (*Ast, err
Enum: e.enum,
}
buffer := new(bytes.Buffer)

unescaped, err := url.QueryUnescape(templateFilename)
if err != nil {
log.Printf("failed to unescape filepath %q: %v", templateFilename, err)
} else {
templateFilename = unescaped
}

tmpl, err := template.New("").Funcs(pgghelpers.ProtoHelpersFuncMap).Parse(templateFilename)
if err != nil {
return nil, err
Expand Down

0 comments on commit 48265e1

Please sign in to comment.