Convert some {Byte,Wide}String::Last() calls to Substr(). [pdfium : main]

1 view
Skip to first unread message

Tom Sepez (Gerrit)

unread,
Apr 7, 2026, 7:15:42 PM (4 days ago) Apr 7
to Pdfium LUCI CQ, pdfium-...@googlegroups.com

Tom Sepez voted and added 1 comment

Votes added by Tom Sepez

Commit-Queue+1

1 comment

File core/fpdfapi/page/cpdf_streamcontentparser.cpp
Line 1269, Patchset 1: defname += name.Substr(7);
Tom Sepez . resolved

This is a perfectly accurate mechanical translation of the original code, but it seems to highlight a pre-existing bug!

`name` starts with the 6-character prefix "Device" (as seen in the `if` condition above).
`Substr(7)` skips the first 7 characters. For "DeviceGray" (length 10), it skips the 'G' at index 6 and returns "ray", resulting in `defname` becoming "Defaultray".
For "DeviceRGB", it results in "DefaultGB", and for "DeviceCMYK" it results in "DefaultMYK".

The intent here is clearly to look up "DefaultGray", "DefaultRGB", and "DefaultCMYK". The author of the original code likely used `7` by mistake, perhaps confusing the length of "Default" (7) with the length of "Device" (6).

Since you're modifying this line, consider fixing this by changing it to `name.Substr(6)`.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: Id0baf48847395be56b15f0e4187bdeecd91b3fd4
Gerrit-Change-Number: 145830
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Sepez <tse...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Comment-Date: Tue, 07 Apr 2026 23:15:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Lei Zhang (Gerrit)

unread,
Apr 7, 2026, 7:24:24 PM (4 days ago) Apr 7
to Tom Sepez, Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
Attention needed from Tom Sepez

Lei Zhang added 1 comment

Commit Message
Line 12, Patchset 3 (Latest):-- Fix one suggested length botch,
Lei Zhang . unresolved

Can that be a separate CL?

Open in Gerrit

Related details

Attention is currently required from:
  • Tom Sepez
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: Id0baf48847395be56b15f0e4187bdeecd91b3fd4
    Gerrit-Change-Number: 145830
    Gerrit-PatchSet: 3
    Gerrit-Owner: Tom Sepez <tse...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Tom Sepez <tse...@chromium.org>
    Gerrit-Comment-Date: Tue, 07 Apr 2026 23:24:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tom Sepez (Gerrit)

    unread,
    Apr 7, 2026, 7:27:47 PM (4 days ago) Apr 7
    to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
    Attention needed from Lei Zhang

    Tom Sepez added 1 comment

    Commit Message
    Line 12, Patchset 3:-- Fix one suggested length botch,
    Lei Zhang . resolved

    Can that be a separate CL?

    Tom Sepez

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Lei Zhang
    Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Id0baf48847395be56b15f0e4187bdeecd91b3fd4
      Gerrit-Change-Number: 145830
      Gerrit-PatchSet: 5
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-Attention: Lei Zhang <the...@chromium.org>
      Gerrit-Comment-Date: Tue, 07 Apr 2026 23:27:45 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Lei Zhang (Gerrit)

      unread,
      Apr 7, 2026, 7:40:10 PM (4 days ago) Apr 7
      to Tom Sepez, Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
      Attention needed from Tom Sepez

      Lei Zhang voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Tom Sepez
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Id0baf48847395be56b15f0e4187bdeecd91b3fd4
      Gerrit-Change-Number: 145830
      Gerrit-PatchSet: 5
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-Attention: Tom Sepez <tse...@chromium.org>
      Gerrit-Comment-Date: Tue, 07 Apr 2026 23:40:06 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Tom Sepez (Gerrit)

      unread,
      Apr 7, 2026, 7:40:34 PM (4 days ago) Apr 7
      to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com

      Tom Sepez voted Commit-Queue+2

      Commit-Queue+2
      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Id0baf48847395be56b15f0e4187bdeecd91b3fd4
      Gerrit-Change-Number: 145830
      Gerrit-PatchSet: 5
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-Comment-Date: Tue, 07 Apr 2026 23:40:31 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Pdfium LUCI CQ (Gerrit)

      unread,
      Apr 7, 2026, 9:16:28 PM (3 days ago) Apr 7
      to Tom Sepez, Lei Zhang, pdfium-...@googlegroups.com

      Pdfium LUCI CQ submitted the change

      Change information

      Commit message:
      Convert some {Byte,Wide}String::Last() calls to Substr().

      Gemini generated patch once human realized that many of these
      less-readable expressions abound.
      Change-Id: Id0baf48847395be56b15f0e4187bdeecd91b3fd4
      Reviewed-by: Lei Zhang <the...@chromium.org>
      Commit-Queue: Tom Sepez <tse...@chromium.org>
      Files:
      • M core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
      • M core/fpdfapi/font/cpdf_cmapparser.cpp
      • M core/fpdfapi/font/cpdf_fontglobals.cpp
      • M core/fpdfapi/page/cpdf_streamcontentparser.cpp
      • M core/fxcrt/css/cfx_cssselector.cpp
      • M core/fxcrt/fx_string.h
      • M core/fxcrt/xml/cfx_xmlelement.cpp
      • M core/fxge/cfx_fontmapper.cpp
      • M fxjs/cjs_publicmethods.cpp
      • M fxjs/cjs_util.cpp
      • M fxjs/xfa/cfxjse_engine.cpp
      • M fxjs/xfa/cfxjse_formcalc_context.cpp
      • M fxjs/xfa/cfxjse_nodehelper.cpp
      • M fxjs/xfa/cfxjse_resolveprocessor.cpp
      • M fxjs/xfa/cjx_instancemanager.cpp
      • M fxjs/xfa/cjx_subform.cpp
      • M xfa/fgas/crt/cfgas_stringformatter.cpp
      • M xfa/fxfa/cxfa_eventparam.cpp
      • M xfa/fxfa/formcalc/cxfa_fmexpression.cpp
      • M xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
      • M xfa/fxfa/parser/cxfa_document_builder.cpp
      • M xfa/fxfa/parser/cxfa_localevalue.cpp
      • M xfa/fxfa/parser/cxfa_node.cpp
      Change size: M
      Delta: 23 files changed, 41 insertions(+), 50 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Lei Zhang
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Id0baf48847395be56b15f0e4187bdeecd91b3fd4
      Gerrit-Change-Number: 145830
      Gerrit-PatchSet: 6
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages