diff options
| author | George Liu <liuxiwei@inspur.com> | 2019-07-19 10:35:40 +0800 |
|---|---|---|
| committer | George Liu <liuxiwei@inspur.com> | 2019-07-22 14:31:24 +0800 |
| commit | 22d7822d5c2e045613e95b8a29df9bc27812b287 (patch) | |
| tree | 5a81c5796df118107e6abaa09ec63e10175a8ccf /app/common/services | |
| parent | 6f7ec80eb14084228cd7d8dae580da4b794c2595 (diff) | |
| download | phosphor-webui-22d7822d5c2e045613e95b8a29df9bc27812b287.tar.gz phosphor-webui-22d7822d5c2e045613e95b8a29df9bc27812b287.zip | |
Fix array index out of bounds exception
We should be verified string length when the phosphor-webui calls the
getFirmwares function to handle the property value of ExtenVersion.
because it is risky to get the first address of array when that is empty
Tested: Built phosphor-webui and get a effective array of titlePart via
console from WEBUI.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ife08d208eb7fbeb71284ae0700fb5d871343a298
Diffstat (limited to 'app/common/services')
| -rw-r--r-- | app/common/services/api-utils.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js index 46d7d4b..5a28294 100644 --- a/app/common/services/api-utils.js +++ b/app/common/services/api-utils.js @@ -1095,12 +1095,15 @@ window.angular && (function(angular) { break; } } - var titlePart = parts.splice(0, numberIndex); - titlePart = titlePart.join(''); - titlePart = titlePart[0].toUpperCase() + - titlePart.substr(1, titlePart.length); - var versionPart = parts.join('-'); - versions.push({title: titlePart, version: versionPart}); + if (numberIndex > 0) { + var titlePart = parts.splice(0, numberIndex); + titlePart = titlePart.join(''); + titlePart = titlePart[0].toUpperCase() + + titlePart.substr(1, titlePart.length); + var versionPart = parts.join('-'); + versions.push( + {title: titlePart, version: versionPart}); + } }); return versions; |

