Skip to content

Commit

Permalink
BOM_UTF8 is actually the first byte, not the last
Browse files Browse the repository at this point in the history
  • Loading branch information
posativ committed Mar 23, 2013
1 parent 1febbe3 commit 8fedb75
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions acrylamid/readers.py
Expand Up @@ -22,7 +22,8 @@
from acrylamid import log from acrylamid import log
from acrylamid.errors import AcrylamidException from acrylamid.errors import AcrylamidException


from acrylamid.utils import cached_property, Metadata, istext, rchop, force_unicode as u from acrylamid.utils import (cached_property, Metadata, istext, rchop, lchop,
force_unicode as u)
from acrylamid.core import cache from acrylamid.core import cache
from acrylamid.filters import FilterTree from acrylamid.filters import FilterTree
from acrylamid.helpers import safeslug, expand, hash from acrylamid.helpers import safeslug, expand, hash
Expand Down Expand Up @@ -269,7 +270,7 @@ def __init__(self, path, conf):


with io.open(path, 'r', encoding='utf-8', errors='replace') as fp: with io.open(path, 'r', encoding='utf-8', errors='replace') as fp:


peak = rchop(fp.read(512), BOM_UTF8) peak = lchop(fp.read(512), BOM_UTF8)
fp.seek(0) fp.seek(0)


if peak.startswith('---\n'): if peak.startswith('---\n'):
Expand Down Expand Up @@ -312,7 +313,7 @@ def lastmodified(self):
def source(self): def source(self):
"""Returns the actual, unmodified content.""" """Returns the actual, unmodified content."""
with io.open(self.filename, 'r', encoding='utf-8') as f: with io.open(self.filename, 'r', encoding='utf-8') as f:
return rchop(''.join(f.readlines()[self.offset:]).strip(), BOM_UTF8) return lchop(''.join(f.readlines()[self.offset:]).strip(), BOM_UTF8)


def __hash__(self): def __hash__(self):
return self.hashvalue return self.hashvalue
Expand Down

0 comments on commit 8fedb75

Please sign in to comment.