From 2095e5c4b35fb9f5993d97fc6b06257ad00eac5f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 21 Dec 2012 20:43:55 +0900 Subject: [PATCH] strip HTML when calculating field checksum (users will need to checkDB) --- anki/models.py | 4 ++-- anki/notes.py | 2 +- anki/utils.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/anki/models.py b/anki/models.py index da63d4079..fca4ba855 100644 --- a/anki/models.py +++ b/anki/models.py @@ -4,7 +4,7 @@ import copy, re from anki.utils import intTime, hexifyID, joinFields, splitFields, ids2str, \ - timestampID, fieldChecksum, json + timestampID, checksum, json from anki.lang import _ from anki.consts import * from anki.hooks import runHook @@ -456,7 +456,7 @@ select id from notes where mid = ?)""" % " ".join(map), s += t['name'] s += t['qfmt'] s += t['afmt'] - return fieldChecksum(s) + return checksum(s) # Required field/text cache ########################################################################## diff --git a/anki/notes.py b/anki/notes.py index bab30fe66..d373d77a6 100644 --- a/anki/notes.py +++ b/anki/notes.py @@ -136,7 +136,7 @@ insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?)""", for flds in self.col.db.list( "select flds from notes where csum = ? and id != ? and mid = ?", csum, self.id or 0, self.mid): - if splitFields(flds)[0] == self.fields[0]: + if stripHTML(splitFields(flds)[0]) == stripHTML(self.fields[0]): return 2 return False diff --git a/anki/utils.py b/anki/utils.py index d2d32ec07..4d1c70d22 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -245,7 +245,7 @@ def checksum(data): def fieldChecksum(data): # 32 bit unsigned number from first 8 digits of sha1 hash - return int(checksum(data.encode("utf-8"))[:8], 16) + return int(checksum(stripHTML(data).encode("utf-8"))[:8], 16) # Temp files ##############################################################################