Przeglądaj źródła

diff 버그 수정

Surplus_Up (2DU) 6 lat temu
rodzic
commit
d8c308c783
3 zmienionych plików z 10 dodań i 13 usunięć
  1. 5 5
      route/tool/func.py
  2. 4 7
      route/view_diff_data.py
  3. 1 1
      version.json

+ 5 - 5
route/tool/func.py

@@ -517,14 +517,14 @@ def diff(seqm):
 
 
     for opcode, a0, a1, b0, b1 in seqm.get_opcodes():
     for opcode, a0, a1, b0, b1 in seqm.get_opcodes():
         if opcode == 'equal':
         if opcode == 'equal':
-            output += [seqm.a[a0:a1]]
+            output += [html.escape(seqm.a[a0:a1])]
         elif opcode == 'insert':
         elif opcode == 'insert':
-            output += ["<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span>"]
+            output += ["<span style='background:#CFC;'>" + html.escape(seqm.b[b0:b1]) + "</span>"]
         elif opcode == 'delete':
         elif opcode == 'delete':
-            output += ["<span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>"]
+            output += ["<span style='background:#FDD;'>" + html.escape(seqm.a[a0:a1]) + "</span>"]
         elif opcode == 'replace':
         elif opcode == 'replace':
-            output += ["<span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>"]
-            output += ["<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span>"]
+            output += ["<span style='background:#FDD;'>" + html.escape(seqm.a[a0:a1]) + "</span>"]
+            output += ["<span style='background:#CFC;'>" + html.escape(seqm.b[b0:b1]) + "</span>"]
 
 
     end = ''.join(output)
     end = ''.join(output)
     end = end.replace('\r\n', '\n')
     end = end.replace('\r\n', '\n')

+ 4 - 7
route/view_diff_data.py

@@ -19,18 +19,15 @@ def view_diff_data_2(conn, name):
         curs.execute(db_change("select data from history where id = ? and title = ?"), [second, name])
         curs.execute(db_change("select data from history where id = ? and title = ?"), [second, name])
         second_raw_data = curs.fetchall()
         second_raw_data = curs.fetchall()
         if second_raw_data:
         if second_raw_data:
-            first_data = html.escape(first_raw_data[0][0])            
-            second_data = html.escape(second_raw_data[0][0])
-
             if first == second:
             if first == second:
-                result = '-'
+                result = ''
             else:            
             else:            
-                diff_data = difflib.SequenceMatcher(None, first_data, second_data)
-                result = re.sub('\r', '', diff(diff_data))
+                diff_data = difflib.SequenceMatcher(None, first_raw_data[0][0], second_raw_data[0][0])
+                result = '<pre>' + diff(diff_data) + '</pre>'
             
             
             return easy_minify(flask.render_template(skin_check(), 
             return easy_minify(flask.render_template(skin_check(), 
                 imp = [name, wiki_set(), custom(), other2([' (' + load_lang('compare') + ')', 0])],
                 imp = [name, wiki_set(), custom(), other2([' (' + load_lang('compare') + ')', 0])],
-                data = '<pre>' + result + '</pre>',
+                data = result,
                 menu = [['history/' + url_pas(name), load_lang('return')]]
                 menu = [['history/' + url_pas(name), load_lang('return')]]
             ))
             ))
 
 

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
 {
     "master" : {
     "master" : {
-        "r_ver" : "v3.1.5-master-18",
+        "r_ver" : "v3.1.5-master-19",
         "c_ver" : "400006",
         "c_ver" : "400006",
         "s_ver" : "6"
         "s_ver" : "6"
     }, "stable" : {
     }, "stable" : {