Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: pdf/pdfium/pdfium_page.cc

Issue 833263003: PDF: Fix extra NUL characters from incorrect WriteInto() calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pdf/pdfium/pdfium_engine.cc ('k') | pdf/pdfium/pdfium_range.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/pdfium/pdfium_page.h" 5 #include "pdf/pdfium/pdfium_page.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return GetDestinationTarget(dest, target); 317 return GetDestinationTarget(dest, target);
318 // TODO(gene): We don't fully support all types of the in-document 318 // TODO(gene): We don't fully support all types of the in-document
319 // links. Need to implement that. There is a bug to track that: 319 // links. Need to implement that. There is a bug to track that:
320 // http://code.google.com/p/chromium/issues/detail?id=55776 320 // http://code.google.com/p/chromium/issues/detail?id=55776
321 } break; 321 } break;
322 case PDFACTION_URI: { 322 case PDFACTION_URI: {
323 if (target) { 323 if (target) {
324 size_t buffer_size = 324 size_t buffer_size =
325 FPDFAction_GetURIPath(engine_->doc(), action, NULL, 0); 325 FPDFAction_GetURIPath(engine_->doc(), action, NULL, 0);
326 if (buffer_size > 1) { 326 if (buffer_size > 1) {
327 void* data = WriteInto(&target->url, buffer_size + 1); 327 void* data = WriteInto(&target->url, buffer_size);
328 FPDFAction_GetURIPath(engine_->doc(), action, data, buffer_size); 328 FPDFAction_GetURIPath(engine_->doc(), action, data, buffer_size);
329 } 329 }
330 } 330 }
331 return WEBLINK_AREA; 331 return WEBLINK_AREA;
332 } break; 332 } break;
333 // TODO(gene): We don't support PDFACTION_REMOTEGOTO and PDFACTION_LAUNCH 333 // TODO(gene): We don't support PDFACTION_REMOTEGOTO and PDFACTION_LAUNCH
334 // at the moment. 334 // at the moment.
335 } 335 }
336 } 336 }
337 337
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 void PDFiumPage::CalculateLinks() { 399 void PDFiumPage::CalculateLinks() {
400 if (calculated_links_) 400 if (calculated_links_)
401 return; 401 return;
402 402
403 calculated_links_ = true; 403 calculated_links_ = true;
404 FPDF_PAGELINK links = FPDFLink_LoadWebLinks(GetTextPage()); 404 FPDF_PAGELINK links = FPDFLink_LoadWebLinks(GetTextPage());
405 int count = FPDFLink_CountWebLinks(links); 405 int count = FPDFLink_CountWebLinks(links);
406 for (int i = 0; i < count; ++i) { 406 for (int i = 0; i < count; ++i) {
407 base::string16 url; 407 base::string16 url;
408 int url_length = FPDFLink_GetURL(links, i, NULL, 0); 408 int url_length = FPDFLink_GetURL(links, i, NULL, 0);
409 if (url_length > 1) { // WriteInto needs at least 2 characters. 409 if (url_length > 0) {
410 unsigned short* data = 410 unsigned short* data =
411 reinterpret_cast<unsigned short*>(WriteInto(&url, url_length + 1)); 411 reinterpret_cast<unsigned short*>(WriteInto(&url, url_length + 1));
raymes 2015/01/14 00:13:12 I just had another look at this and I think that w
Lei Zhang 2015/01/14 01:21:54 Gah! I will make another CL...
Deepak 2015/01/14 03:50:38 I personally don't think that FPDFLink_GetURL() gi
412 FPDFLink_GetURL(links, i, data, url_length); 412 FPDFLink_GetURL(links, i, data, url_length);
413 } 413 }
414 Link link; 414 Link link;
415 link.url = base::UTF16ToUTF8(url); 415 link.url = base::UTF16ToUTF8(url);
416 416
417 // If the link cannot be converted to a pp::Var, then it is not possible to 417 // If the link cannot be converted to a pp::Var, then it is not possible to
418 // pass it to JS. In this case, ignore the link like other PDF viewers. 418 // pass it to JS. In this case, ignore the link like other PDF viewers.
419 // See http://crbug.com/312882 for an example. 419 // See http://crbug.com/312882 for an example.
420 pp::Var link_var(link.url); 420 pp::Var link_var(link.url);
421 if (!link_var.is_string()) 421 if (!link_var.is_string())
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 page_->loading_count_--; 496 page_->loading_count_--;
497 } 497 }
498 498
499 PDFiumPage::Link::Link() { 499 PDFiumPage::Link::Link() {
500 } 500 }
501 501
502 PDFiumPage::Link::~Link() { 502 PDFiumPage::Link::~Link() {
503 } 503 }
504 504
505 } // namespace chrome_pdf 505 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_engine.cc ('k') | pdf/pdfium/pdfium_range.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698