External Method-1-0-0 returns 404 Error when module name or function name has a trailing space

Bug #423171 reported by Mark Phillips
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Wishlist
Unassigned

Bug Description

When filling out the Add External Method form, it is possible to include leading or trailing spaces in the module or function name. If either or both names have a leading/trailing space, the Add External Method returns and error 404 - the function or module cannot be found. It is easy for a user to incorporate a trailing space by either typing the names or cutting and pasting the names from another source.

An example stack trace with a space after the module name:
Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Products.ExternalMethod.ExternalMethod, line 59, in manage_addExternalMethod
  Module Products.ExternalMethod.ExternalMethod, line 111, in __init__
  Module Products.ExternalMethod.ExternalMethod, line 134, in manage_edit
  Module Products.ExternalMethod.ExternalMethod, line 141, in getFunction
  Module App.Extensions, line 120, in getObject
NotFound: The specified module, <em>WorkflowEmailScripts </em>, couldn't be found.

An example stack trace with a trailing space after the function name:
Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Products.ExternalMethod.ExternalMethod, line 59, in manage_addExternalMethod
  Module Products.ExternalMethod.ExternalMethod, line 111, in __init__
  Module Products.ExternalMethod.ExternalMethod, line 134, in manage_edit
  Module Products.ExternalMethod.ExternalMethod, line 141, in getFunction
  Module App.Extensions, line 158, in getObject
   - __traceback_info__: ('/opt/Plone-2.5.5/zeocluster/client1/Extensions/WorkflowEmailScripts.py', 'WorkflowEmailScripts')
NotFound: The specified object, <em>edit_new_content </em>, was not found in module, <em>WorkflowEmailScripts</em>.

Suggested Solution:
In Products.ExternalMethod.py these lines -
    56 module=str(module)
    57 function=str(function)

should be changed to
    56 module=str(module).strip()
    57 function=str(function).strip()

It may be a good idea to make these changes as well:
     54 id=str(id)
     55 title=str(title)

     54 id=str(id).strip()
     55 title=str(title).strip()

This bug is easy to reproduce:
1. Create an python script with one function
2. Add the script to the Extensions directory
3. Go to the ZMI
4. Select Add External Method
5. Type the Id, Title, Module name for the python script, and Function name in the python script
6. Add a trailing or leading space to either the Function name or Module name
7 Click Add, and you will get a 404 error and the stack trace above.
8. Remove the trailing or leading space and the External method will be loaded correctly.

Changed in zope2:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope2 project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope2.

Changed in zope2:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.