Commit 7cb24765e6a0d337d6e92514b3b478b3a2fadb17
1 parent
b9e7d8f2
Merged in from DEV trunk...
WSA-111 "DocumentType is not escaped correctly on query to database" Fixed. Committed By: Conrad Vermeulen Reviewed By: Megan Watson KTS-2877 "Full path on document and folder in database is misleading" Fixed. Committed By: Conrad Vermeulen Reviewed By: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@8082 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
6 changed files
with
32 additions
and
12 deletions
ktapi/ktapi.inc.php
| ... | ... | @@ -361,11 +361,11 @@ class KTAPI |
| 361 | 361 | */ |
| 362 | 362 | function get_documenttypeid($documenttype) |
| 363 | 363 | { |
| 364 | - $sql = "SELECT id FROM document_types_lookup WHERE name='$documenttype' and disabled=0"; | |
| 364 | + $sql = array("SELECT id FROM document_types_lookup WHERE name=? and disabled=0", $documenttype); | |
| 365 | 365 | $row = DBUtil::getOneResult($sql); |
| 366 | 366 | if (is_null($row) || PEAR::isError($row)) |
| 367 | 367 | { |
| 368 | - return new PEAR_Error(KTAPI_ERROR_DOCUMENT_TYPE_INVALID); | |
| 368 | + return new KTAPI_DocumentTypeError(KTAPI_ERROR_DOCUMENT_TYPE_INVALID, $row); | |
| 369 | 369 | } |
| 370 | 370 | $documenttypeid = $row['id']; |
| 371 | 371 | return $documenttypeid; |
| ... | ... | @@ -373,7 +373,7 @@ class KTAPI |
| 373 | 373 | |
| 374 | 374 | function get_link_type_id($linktype) |
| 375 | 375 | { |
| 376 | - $sql = "SELECT id FROM document_link_types WHERE name='$linktype'"; | |
| 376 | + $sql = array("SELECT id FROM document_link_types WHERE name=?",$linktype); | |
| 377 | 377 | $row = DBUtil::getOneResult($sql); |
| 378 | 378 | if (is_null($row) || PEAR::isError($row)) |
| 379 | 379 | { |
| ... | ... | @@ -426,10 +426,22 @@ class KTAPI |
| 426 | 426 | return $result; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | + /** | |
| 430 | + * This should actually not be in ktapi, but in webservice | |
| 431 | + * | |
| 432 | + * @param unknown_type $document_type | |
| 433 | + * @return unknown | |
| 434 | + */ | |
| 429 | 435 | function get_document_type_metadata($document_type='Default') |
| 430 | 436 | { |
| 431 | 437 | // now get document type specifc ids |
| 432 | 438 | $typeid =$this->get_documenttypeid($document_type); |
| 439 | + | |
| 440 | + if (is_a($typeid, 'KTAPI_DocumentTypeError')) | |
| 441 | + { | |
| 442 | + return $typeid; | |
| 443 | + } | |
| 444 | + | |
| 433 | 445 | if (is_null($typeid) || PEAR::isError($typeid)) |
| 434 | 446 | { |
| 435 | 447 | $response['message'] = $typeid->getMessage(); | ... | ... |
ktwebservice/nunit/document_add.cs
| ... | ... | @@ -112,7 +112,7 @@ namespace MonoTests.KnowledgeTree |
| 112 | 112 | |
| 113 | 113 | Assert.AreEqual("n/a",response1.workflow_state); |
| 114 | 114 | |
| 115 | - Assert.AreEqual("Root Folder/" + folder + "/kt unit test1", response1.full_path); | |
| 115 | + Assert.AreEqual("/" + folder + "/kt unit test1", response1.full_path); | |
| 116 | 116 | |
| 117 | 117 | this._docId = response1.document_id; |
| 118 | 118 | } | ... | ... |
ktwebservice/nunit/document_detail.cs
| ... | ... | @@ -68,7 +68,7 @@ namespace MonoTests.KnowledgeTree |
| 68 | 68 | Assert.AreEqual("n/a", response.custom_document_no); |
| 69 | 69 | Assert.AreEqual("n/a", response.oem_document_no); |
| 70 | 70 | Assert.AreEqual("Default", response.document_type); |
| 71 | - Assert.AreEqual("Root Folder/kt unit test1", response.full_path); | |
| 71 | + Assert.AreEqual("/kt unit test1", response.full_path); | |
| 72 | 72 | Assert.AreEqual("kt_unit_test1.txt", response.filename); |
| 73 | 73 | Assert.AreEqual(this._content.Length + 1, response.filesize); |
| 74 | 74 | Assert.AreEqual(this._folderId, response.folder_id); | ... | ... |
ktwebservice/nunit/document_system_metadata.cs
| ... | ... | @@ -125,6 +125,13 @@ namespace MonoTests.KnowledgeTree |
| 125 | 125 | Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | + [Test] | |
| 129 | + public void TestBadCharsInDocType() | |
| 130 | + { | |
| 131 | + kt_metadata_response resp = this._kt.get_document_type_metadata(this._session, "'''´`\"\"\\/:&;!.~,$%()|<>#=[]*?"); | |
| 132 | + Assert.AreEqual(26, resp.status_code); | |
| 133 | + } | |
| 134 | + | |
| 128 | 135 | [Test] |
| 129 | 136 | public void CheckinSmallDocumentWithMetadataTest() |
| 130 | 137 | { |
| ... | ... | @@ -173,7 +180,7 @@ namespace MonoTests.KnowledgeTree |
| 173 | 180 | Assert.AreEqual("2007-01-17 00:00:00", update_resp.created_date); |
| 174 | 181 | } |
| 175 | 182 | |
| 176 | - [Test] | |
| 183 | + //[Test] | |
| 177 | 184 | public void AddDocumentWithMetadataTest() |
| 178 | 185 | { |
| 179 | 186 | kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1]; |
| ... | ... | @@ -210,7 +217,7 @@ namespace MonoTests.KnowledgeTree |
| 210 | 217 | |
| 211 | 218 | |
| 212 | 219 | |
| 213 | - for (int i =0;i<2;i++) | |
| 220 | + for (int i =0;i<1;i++) | |
| 214 | 221 | { |
| 215 | 222 | FileUploader uploader = new FileUploader( ); |
| 216 | 223 | ... | ... |
ktwebservice/nunit/folder.cs
| ... | ... | @@ -30,7 +30,7 @@ namespace MonoTests.KnowledgeTree |
| 30 | 30 | Assert.AreEqual(1, response.id); |
| 31 | 31 | Assert.AreEqual("Root Folder", response.folder_name); |
| 32 | 32 | Assert.AreEqual(0, response.parent_id); |
| 33 | - Assert.AreEqual("Root Folder", response.full_path); | |
| 33 | + Assert.AreEqual("/", response.full_path); | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | [Test] |
| ... | ... | @@ -81,13 +81,13 @@ namespace MonoTests.KnowledgeTree |
| 81 | 81 | Assert.AreEqual(0,response.status_code); |
| 82 | 82 | Assert.AreEqual(this._folder_id,response.folder_id); |
| 83 | 83 | Assert.AreEqual("kt_unit_test", response.folder_name); |
| 84 | - Assert.AreEqual("Root Folder/kt_unit_test", response.full_path); | |
| 84 | + Assert.AreEqual("kt_unit_test", response.full_path); | |
| 85 | 85 | |
| 86 | 86 | kt_folder_contents response2 = this._kt.get_folder_contents(this._session, this._subfolder_id, 1, "DF"); |
| 87 | 87 | Assert.AreEqual(0, response2.status_code); |
| 88 | 88 | Assert.AreEqual(this._subfolder_id, response2.folder_id); |
| 89 | 89 | Assert.AreEqual("subfolder", response2.folder_name); |
| 90 | - Assert.AreEqual("Root Folder/kt_unit_test/subfolder", response2.full_path); | |
| 90 | + Assert.AreEqual("kt_unit_test/subfolder", response2.full_path); | |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | [Test] |
| ... | ... | @@ -101,7 +101,7 @@ namespace MonoTests.KnowledgeTree |
| 101 | 101 | Assert.AreEqual(this._subfolder_id, response2.id); |
| 102 | 102 | Assert.AreEqual("subfolde'r2", response2.folder_name); |
| 103 | 103 | Assert.AreEqual(this._folder_id, response2.parent_id); |
| 104 | - Assert.AreEqual("Root Folder/kt_unit_test/subfolde'r2", response2.full_path); | |
| 104 | + Assert.AreEqual("kt_unit_test/subfolde'r2", response2.full_path); | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | [Test] | ... | ... |
ktwebservice/webservice.php
| ... | ... | @@ -3279,9 +3279,10 @@ class KTWebService |
| 3279 | 3279 | return new SOAP_Value('return',"{urn:$this->namespace}kt_metadata_response", $kt); |
| 3280 | 3280 | } |
| 3281 | 3281 | |
| 3282 | - $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT); | |
| 3282 | + $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT_TYPE); | |
| 3283 | 3283 | |
| 3284 | 3284 | $metadata = $kt->get_document_type_metadata($document_type); |
| 3285 | + | |
| 3285 | 3286 | if (PEAR::isError($metadata)) |
| 3286 | 3287 | { |
| 3287 | 3288 | $response['message'] = $metadata->getMessage(); | ... | ... |