Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchableText indexer is broken #1844

Closed
agitator opened this issue Nov 18, 2016 · 9 comments
Closed

SearchableText indexer is broken #1844

agitator opened this issue Nov 18, 2016 · 9 comments

Comments

@agitator
Copy link
Member

agitator commented Nov 18, 2016

coredev 5.1

       if IRichTextValue.providedBy(textvalue):
            transforms = getToolByName(obj, 'portal_transforms')
            text = transforms.convertTo(
                'text/plain',
                safe_unicode(textvalue.output).encode('utf8'),
                mimetype=textvalue.outputMimeType,
            ).getData().strip()

https://github.com/plone/plone.app.contenttypes/blob/master/plone/app/contenttypes/indexers.py#L46

as it looks, the transform to safe-html fails somehow and returns None, which makes it kind of hard to getData() from after... transform to text/plain works

no idea what introduced that bug
would a transform to just text be (safe) enough too?

@gforcada
Copy link
Sponsor Contributor

@agitator and that's related to the SearchableText?

@jensens
Copy link
Sponsor Member

jensens commented Nov 18, 2016

nice catch :/

@thet
Copy link
Member

thet commented Nov 18, 2016

@agitator - this transform transforms to text/plain , not safe html.

also, can you provide the data, which fails transforming?

@agitator
Copy link
Member Author

output.mimetype sets the target transform to safe-html

Was there a change in the field definition?

@agitator
Copy link
Member Author

(Pdb++) textvalue.output
u'<p>Text1 Text2 Text3</p>'

(Pdb++) textvalue.outputMimeType
'text/x-html-safe'

(Pdb++) transforms.convertTo('text/plain',safe_unicode(textvalue.output).encode('utf8'),mimetype=textvalue.outputMimeType).getData()
*** AttributeError: 'NoneType' object has no attribute 'getData'

(Pdb++) transforms.convertTo('text/plain',safe_unicode(textvalue.output).encode('utf8')).getData()
' Text1 Text2 Text3 '

Do we even have to check for the textvalue.outputMimeType?

@jensens
Copy link
Sponsor Member

jensens commented Nov 24, 2016

it does: transforms.convertTo('text/plain', u'<p>Text1 Text2 Text3</p>', mimetype='text/x-html-safe')

But mimetype kwarg is expected to be the source mimetype, which is here text/html. So this is wrong.

I think there is probably no converter for text/x-html-safe to text/plain, therefore the result is None.

Pass in the inputMimeType instead (guessed name, lookup what's the attribute name if wrong).

@jensens
Copy link
Sponsor Member

jensens commented Nov 24, 2016

@thet, this might explain why we have problems with indexing at AAF.

@agitator
Copy link
Member Author

agitator commented Dec 2, 2016

fixed with plone/plone.app.contenttypes#380

@agitator agitator closed this as completed Dec 2, 2016
@thet
Copy link
Member

thet commented Dec 2, 2016

+1. doesn't make too much sense to first transform to outputmimetype (which is cached by plone.app.textfield) and then transform to text/plain.
using the values original mimetype feels better.
i hope this solves our indexing problems, @jensens :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants