invalide identifier with colon in search/replace

Bug #1928579 reported by 1pogaz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

When your try to modify all identifiers (*) with the template function, if the value of an output identifier contains a colon (like url:http://www.gutenberg.org/ebooks/17691 ) the field will not be modified.
Look at the attached image for example. The preview works, but the fields are not modified.

I discovered the problem when I created a plugin (Mass Search/Replace) that uses the same code as MetadataBulkDialog() from metadata_bulk.py
Apparently, the Search/Replace in the main interface does not raise the error.

if dst_id_type and dst_id_type != '*':
    v = ''.join(val)
    ids = mi.get(dest)
    ids[dst_id_type] = v
    val = ids
else:
    try:
        val = dict([(t.split(':')) for t in val]) ## <= This is where the error occurs
    except:
        raise Exception(_('Invalid identifier string. It must be a '
                          'comma-separated list of pairs of '
                          'strings separated by a colon'))

EDIT: FIX?
val = dict([(t.split(':', 1)) for t in val])

Revision history for this message
1pogaz (1pogaz) wrote :
description: updated
1pogaz (1pogaz)
description: updated
1pogaz (1pogaz)
description: updated
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
Revision history for this message
Charles Haley (cbhaley) wrote :

@kovid: the fix you made doesn't show any error messages to the user. The Exception is tossed by the function dispatcher.

I have a fix that shows error messages and gives the user the option to stop processing. Do you want me to create a PR for it?

Revision history for this message
Charles Haley (cbhaley) wrote :

s/tossed/ignored/

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1928579

Sure send it

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers