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

Fix a null pointer in OperationView.js in headers #1122

Closed
wants to merge 1 commit into from

Conversation

tomdwaggy
Copy link

The check for "Download" content type in OperationView.js does not
determine if the header is available before checking the regular
expression. If the header is not available, then the operation will
fail and the behavior will resemble:

#1109

This issue appears to extend to other content types, including
application/yaml, or any not explicitly defined before the
"Download" conditional. Simply checking for a null value before
testing the regular expression is enough to get things to work
properly again.

The check for "Download" content type in OperationView.js does not
determine if the header is available before checking the regular
expression. If the header is not available, then the operation will
fail and the behavior will resemble:

swagger-api#1109

This issue appears to extend to other content types, including
application/xml, or any not explicitly defined before the
"Download" conditional. Simply checking for a null value before
testing the regular expression is enough to get things to work
properly again.
@webron
Copy link
Contributor

webron commented Apr 24, 2015

@mohsen1 - can you please review this one? I imagine it'd need a rebase but no point asking for one if it's not the right solution.

@mohsen1
Copy link
Contributor

mohsen1 commented Apr 24, 2015

Null pointer is one issue, the other issue is we're using .test on strings. It should be on the RegEx.

(headers['Content-Disposition'] && headers['Content-Disposition'].test(/attachment/)) should be (headers['Content-Disposition'] && (/attachment/)).test(headers['Content-Disposition'])

@webron
Copy link
Contributor

webron commented Apr 24, 2015

@TomDataworks - can you rebase the PR and make the additional change @mohsen1 suggested? Looks like this could help us solve several issues.

@rswijesena
Copy link

I tested PR manually, Error: TypeError: headers['Content-Disposition'] is undefined is fixed now.
Thanks.

This code part does the trick.

  • } else if (headers['Content-Disposition'].test(/attachment/) ||
  •           headers['content-disposition'].test(/attachment/) ||
    
  •           headers['Content-Description'].test(/File Transfer/) ||
    
  •           headers['content-description'].test(/File Transfer/)) {
    
  • } else if ((headers['Content-Disposition'] && headers['Content-Disposition'].test(/attachment/)) ||
  •           (headers['content-disposition'] && headers['content-disposition'].test(/attachment/)) ||
    
  •           (headers['Content-Description'] && headers['Content-Description'].test(/File Transfer/)) ||
    
  •           (headers['content-description'] && headers['content-description'].test(/File Transfer/))) {
    

fehguy added a commit that referenced this pull request May 8, 2015
@fehguy fehguy closed this May 8, 2015
Jonahss pushed a commit to eaze/swagger-ui that referenced this pull request Aug 12, 2016
vincent-zurczak pushed a commit to roboconf/swagger-ui that referenced this pull request Aug 19, 2016
JuanSW18 pushed a commit to Digital-Paw/digital-paw-swagger-ui that referenced this pull request Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants